JuliusBrussee/caveman · error

cachebench: replay observation is not bound to replay…

Error message

cachebench: replay observation is not bound to replay evidence

What it means

Raised by validateReplayResult for a successful replay: the bound ObservationRecord fails the cross-check against the evidence record — request_id, provider, epoch, request body digest (vs TraceBodySHA256), provider evidence digest, eligible input tokens, or applied flag disagree. The observation must be the exact counterpart of the evidence, preventing evidence/observation mismatches.

Solutions

  1. Regenerate the observation from the same replay attempt as the evidence
  2. Check that digest fields are copied from the same raw bytes on both records
  3. Never mix observations from one run with evidence from another
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cacheengine/cachebench/replay.go:838 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/ff9979b38cd7876e. Report an issue: GitHub.

Appendix: source

Thrown at cacheengine/cachebench/replay.go:838

		return err
	}
	return emit(result)
}

func validateReplayResult(result ReplayResult) error {
	if err := validateReplayEvidence(result.Evidence); err != nil {
		return err
	}
	if result.Evidence.Success {
		if result.Observation == nil || len(result.ProviderResponse) == 0 || len(result.VerificationEvidence) == 0 || bodyDigest(result.ProviderResponse) != result.Evidence.ProviderEvidenceSHA256 || bodyDigest(result.VerificationEvidence) != result.Evidence.QualityEvidenceSHA256 {
			return errors.New("cachebench: successful replay result is not bound to retained artifacts")
		}
		if err := validateObservationRecords([]ObservationRecord{*result.Observation}); err != nil {
			return err
		}
		observation := result.Observation
		if observation.RequestID != result.Evidence.RequestID || observation.Provider != result.Evidence.Provider || observation.Epoch != result.Evidence.Epoch || observation.RequestBodySHA256 != result.Evidence.TraceBodySHA256 || observation.ProviderEvidenceSHA256 != result.Evidence.ProviderEvidenceSHA256 || observation.EligibleInputTokens != result.Evidence.ProviderTotalInputTokens || observation.Applied != result.Evidence.Applied || observation.EngineDecision != result.Evidence.Decision || observation.EngineReason != result.Evidence.Reason || observation.Attribution != result.Evidence.Attribution || !slices.Equal(observation.OptimizerIDs, result.Evidence.OptimizerIDs) || observation.QualityPassed != result.Evidence.QualityPassed || observation.QualityEvidenceSHA256 != result.Evidence.QualityEvidenceSHA256 || observation.QualityVerifier != result.Evidence.QualityVerifier || bodyDigest(observation.Usage) != result.Evidence.ProviderUsageSHA256 {
			return errors.New("cachebench: replay observation is not bound to replay evidence")
		}
		return nil
	}
	if result.Observation != nil || len(result.VerificationEvidence) != 0 {
		return errors.New("cachebench: failed replay result contains success-only artifacts")
	}
	if len(result.ProviderResponse) > 0 {
		if bodyDigest(result.ProviderResponse) != result.Evidence.ProviderEvidenceSHA256 {
			return errors.New("cachebench: failed replay response is not bound to evidence")
		}
	} else if result.Evidence.ProviderEvidenceSHA256 != "" {
		return errors.New("cachebench: failed replay evidence references missing response")
	}
	return nil
}

func validTaskVerification(verification TaskVerification) bool {
	return validBoundedText(verification.Verifier, 256, false) && validUniqueJSONObject(verification.Evidence)

View on GitHub (pinned to 766dce6b13)