JuliusBrussee/caveman · error
session-value artifact schema mismatch
Error message
session-value artifact schema mismatch
What it means
ValidateSessionValueArtifact first checks that the artifact declares the exact schema pair the evaluator understands: Schema == "caveman.router.session-value-policy.v1" and StateSchemaVersion == "router-state-metadata-v1". Any other pair is rejected before tenant, pool, lineage, or numeric checks run, because the evaluator cannot interpret fields from a different schema generation.
Solutions
- Regenerate or re-ship the artifact with the current trainer so Schema and StateSchemaVersion match the deployed router constants.
- When debugging, check these two fields first — all later validation (tenant, pool, lineage, window) only runs after this check passes.
- Pin router and trainer versions together in the release pipeline so schema constants cannot skew.
Example fix
// before
{
"schema": "caveman.router.session-value-policy.v0",
"state_schema_version": "router-state-metadata-v0"
}
// after
{
"schema": "caveman.router.session-value-policy.v1",
"state_schema_version": "router-state-metadata-v1"
} Defensive patterns
Strategy: validation
Validate before calling
// Before full validation, compare against the exported constants.
if artifact.Schema != routing.SessionValueArtifactSchema ||
artifact.StateSchemaVersion != routing.SessionValueStateSchema {
return fmt.Errorf("artifact schema %q/%q not supported by this router (want %q/%q); regenerate with the matching trainer",
artifact.Schema, artifact.StateSchemaVersion,
routing.SessionValueArtifactSchema, routing.SessionValueStateSchema)
} Type guard
func artifactSchemaCompatible(a routing.SessionValuePolicyArtifact) bool {
return a.Schema == routing.SessionValueArtifactSchema &&
a.StateSchemaVersion == routing.SessionValueStateSchema
} Prevention
- Check schema fields first when loading artifacts — they short-circuit every later diagnostic.
- Ship trainer and router in lockstep so the constants cannot diverge.
- Include the schema strings in artifact filenames or registry metadata for quick visual audits.
When it happens
Trigger: Loading an artifact produced by an older or newer trainer where either constant was renamed or bumped; hand-edited JSON; mixing two artifact streams so the policy schema no longer matches the state-metadata schema the router persists.
Common situations: Router upgraded across a schema version change while old artifacts are still referenced by config; trainer and router released out of sync; artifact files copied between environments running different versions.
Related errors
- session-value artifact version identity invalid
- cave_context_ir_unknown_schema
- session-value artifact action identity or order invalid
- session-value artifact candidate pool mismatch
- session-value artifact confidence policy invalid
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/7553591703fbc8d6.
Report an issue: GitHub.
Appendix: source
Thrown at proxy/routing/session_value.go:165
if err != nil {
return "", fmt.Errorf("marshal session-value artifact: %w", err)
}
sum := sha256.Sum256(raw)
return "sha256:" + hex.EncodeToString(sum[:]), nil
}
func SealSessionValueArtifact(artifact SessionValuePolicyArtifact) (SessionValuePolicyArtifact, error) {
hash, err := ComputeSessionValueArtifactHash(artifact)
if err != nil {
return SessionValuePolicyArtifact{}, err
}
artifact.ArtifactHash = hash
return artifact, nil
}
func ValidateSessionValueArtifact(artifact SessionValuePolicyArtifact, organizationID, projectID, candidatePoolHash string, now time.Time) error {
if artifact.Schema != SessionValueArtifactSchema || artifact.StateSchemaVersion != SessionValueStateSchema {
return errors.New("session-value artifact schema mismatch")
}
if strings.TrimSpace(artifact.OrganizationID) == "" || artifact.OrganizationID != strings.TrimSpace(organizationID) ||
strings.TrimSpace(artifact.ProjectID) == "" || artifact.ProjectID != strings.TrimSpace(projectID) {
return errors.New("session-value artifact tenant scope mismatch")
}
if artifact.PolicyVersion <= 0 || artifact.RouterVersion != SessionValueRouterVersion || strings.TrimSpace(artifact.EstimatorVersion) == "" {
return errors.New("session-value artifact version identity invalid")
}
if !validCompactPoolHash(artifact.CandidatePoolHash) || artifact.CandidatePoolHash != candidatePoolHash {
return errors.New("session-value artifact candidate pool mismatch")
}
if !validSHA256Ref(artifact.TrainingManifestHash) || strings.TrimSpace(artifact.TrainingExtractor) == "" || strings.TrimSpace(artifact.OutcomeContractVersion) == "" {
return errors.New("session-value artifact training lineage invalid")
}
if artifact.ValidFrom.IsZero() || artifact.ValidUntil.IsZero() || !artifact.ValidUntil.After(artifact.ValidFrom) || now.Before(artifact.ValidFrom) || !now.Before(artifact.ValidUntil) {
return errors.New("session-value artifact outside validity window")
}
if artifact.RollbackParentHash != "" && (!validSHA256Ref(artifact.RollbackParentHash) || artifact.RollbackParentHash == artifact.ArtifactHash) {View on GitHub (pinned to 766dce6b13)