JuliusBrussee/caveman · error

native runtime: decode decision

Error message

native runtime: decode decision: %w

What it means

ExplainDecision could not JSON-decode the persisted decision record from the task store into the expected schema fields, typically because the stored record is corrupt, truncated, or was written by an incompatible schema version.

Solutions

  1. Inspect the stored decision record for corruption or truncation
  2. Regenerate the decision via the runtime and retry the explanation
  3. Check for a schema migration mismatch between writer and reader
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at proxy/internal/nativeruntime/explain.go:55 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/414efd931e97feba. Report an issue: GitHub.

Appendix: source

Thrown at proxy/internal/nativeruntime/explain.go:55

	object, err := store.FindTaskDecision(decisionID)
	if err != nil {
		return DecisionExplanation{}, err
	}
	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 766dce6b13)