affaan-m/ECC · error · ContractError

anchor evidence source duration is not bound to its receipt…

Error message

anchor evidence source duration is not bound to its receipt reference

What it means

ContractError raised when the reference_durations lookup is active and the anchor's source_duration does not match the duration recorded for its source_ref_sha256 digest in the receipt references, or the digest is missing/unresolvable. This binds anchor evidence timing to the immutable receipt for the source media, preventing anchors that claim durations inconsistent with the actual reference.

Solutions

  1. Regenerate the anchor's source_ref_sha256 and source_duration from the current receipt so they match reference_durations.
  2. Verify the digest is a full lowercase hex sha256 string present in reference_durations.
  3. Update source media references after any re-encode that changes duration.
  4. Catch ContractError and diff anchor.source_duration against reference_durations.get(digest) to identify the mismatch.

Example fix

// before
anchor = {..., "source_ref_sha256": "abc123", "source_duration": 12.0}
# receipt says reference_durations["abc123"] == 10.0
// after
anchor = {..., "source_ref_sha256": "abc123", "source_duration": 10.0}  # matches receipt
Defensive patterns

Strategy: validation

Validate before calling

digest = anchor.get("source_ref_sha256")
expected = reference_durations.get(digest) if isinstance(digest, str) else None
if expected is None or anchor.get("source_duration") != expected:
    raise ValueError("anchor source_duration does not match receipt reference")

Type guard

def anchor_bound_to_reference(anchor, reference_durations) -> bool:
    digest = anchor.get("source_ref_sha256")
    if not isinstance(digest, str):
        return False
    return reference_durations.get(digest) == anchor.get("source_duration")

Try / catch

try:
    validate_effect_recipe(recipe, reference_durations)
except ContractError as exc:
    if "not bound to its receipt reference" in str(exc):
        refresh_anchor_from_receipt(anchor, receipts)
        validate_effect_recipe(recipe, reference_durations)
    else:
        raise

Prevention

When it happens

Trigger: Calling validate_effect_recipe with reference_durations provided and an anchor whose source_ref_sha256 is absent or not a string, is not present in reference_durations, or whose source_duration differs from reference_durations[digest].

Common situations: Hand-editing source_duration after the receipt was generated; pointing the anchor at the wrong reference digest; regenerating source media (new duration) without refreshing the receipt and anchor; truncated digests or casing differences in the sha256 string.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/1b44a75ed3ad1a05. Report an issue: GitHub.

Appendix: source

Thrown at skills/taste-application/scripts/tasteforge/contract.py:251

            required = {
                "mode", "target", "source_ref_sha256", "evidence_time",
                "source_duration", "lost_policy",
            }
            if not isinstance(anchor, dict) or not required.issubset(anchor):
                raise ContractError(f"CV effect {event.get('effect')} lacks a valid subject anchor")
            if anchor.get("mode") not in {"object_track", "point_track", "segmentation_track"}:
                raise ContractError(f"CV effect {event.get('effect')} has an invalid subject anchor")
            if anchor.get("lost_policy") != "disable_effect_until_track_recovers":
                raise ContractError(f"CV effect {event.get('effect')} must fail closed on anchor loss")
            _validate_media_time(
                anchor.get("evidence_time"), anchor.get("source_duration"),
                label="anchor evidence time",
            )
            if reference_durations is not None:
                digest = anchor.get("source_ref_sha256")
                expected_duration = reference_durations.get(digest) if isinstance(digest, str) else None
                if expected_duration is None or anchor.get("source_duration") != expected_duration:
                    raise ContractError("anchor evidence source duration is not bound to its receipt reference")
    for event in events:
        placement = event.get("placement")
        if not isinstance(placement, dict) or not {"safe_area", "max_coverage", "occlusion_policy"}.issubset(placement):
            raise ContractError(f"effect {event.get('effect')} lacks placement constraints")


def validate_provenance(payload: dict[str, Any]) -> None:
    """Require every declared rule to cite immutable, timestamped evidence."""
    rules = payload.get("rules")
    if not isinstance(rules, list) or not rules:
        raise ContractError("provenance must contain derived rules")
    for rule in rules:
        evidence = rule.get("evidence")
        if not isinstance(evidence, list) or not evidence:
            raise ContractError(f"rule {rule.get('rule_id')} lacks reference evidence")
        for item in evidence:
            digest = item.get("reference_sha256")
            if not isinstance(digest, str) or len(digest) != 64:

View on GitHub (pinned to 8321021c54)