{"record":{"id":"c47f5408ecfc09d0","repo":"affaan-m/ECC","slug":"reference-probe-numeric-evidence-must-be-finite-real-values","errorCode":null,"errorMessage":"reference probe numeric evidence must be finite real values","messagePattern":"reference probe numeric evidence must be finite real values","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/workflow.py","lineNumber":129,"sourceCode":"            try:\n                rebound_stat = os.fstat(rebound)\n                if (rebound_stat.st_dev, rebound_stat.st_ino) != (before.st_dev, before.st_ino):\n                    raise ValueError(\"reference source identity changed during media probing\")\n            finally:\n                os.close(rebound)\n            return measured, total, source_digest\n    finally:\n        os.close(descriptor)\n\n\ndef _finite_real(value: Any) -> bool:\n    return isinstance(value, (int, float)) and not isinstance(value, bool) and math.isfinite(value)\n\n\ndef _validate_probe(measured: dict[str, Any]) -> float:\n    def require_finite_evidence(value: Any) -> None:\n        if isinstance(value, bool):\n            raise ValueError(  # noqa: TRY004 - one bounded invalid-media error family\n                \"reference probe numeric evidence must be finite real values\"\n            )\n        if isinstance(value, (int, float)):\n            if not math.isfinite(value):\n                raise ValueError(\"reference probe numeric evidence must be finite real values\")\n        elif isinstance(value, dict):\n            for nested in value.values():\n                require_finite_evidence(nested)\n        elif isinstance(value, list):\n            for nested in value:\n                require_finite_evidence(nested)\n\n    require_finite_evidence(measured)\n    duration = measured.get(\"duration\")\n    if not _finite_real(duration):\n        raise ValueError(\"reference probe duration must be finite and positive\")\n    duration = cast(float, duration)\n    if float(duration) <= 0:","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/workflow.py#L111-L147","documentation":"validate_probe (via its require_finite_evidence closure in _validate_probe) walks the entire probe result dict and rejects any numeric leaf that is not a finite real number: NaN, +/-inf, or a bool (booleans are explicitly rejected so 'truthy' flags cannot masquerade as measurements). The probe contract requires that every numeric value in the measured evidence is a genuine finite float/int, because these values feed fingerprints, prompts, and timeline math.","triggerScenarios":"run_workflow() -> _stable_probe(path, probe) -> _validate_probe(measured) when the injected probe callable (the `probe` argument to run_workflow, or probe_media) returns a dict containing a bool value (e.g. \"ok\": True), or a NaN/Infinity from a division like 0/0 fps or float('inf') duration.","commonSituations":"A custom probe stub returning JSON-ish mock data that includes booleans; probe math dividing by zero frame duration producing inf; ffprobe-like sources returning 'N/A' parsed via float() into nan; test doubles returning None inside nested lists that later coerce badly.","solutions":["Fix the probe callable to return only finite int/float measurements — remove boolean fields or convert them to numeric encodings.","Guard divisions in the probe (frame rate, duration) against zero denominators and fall back to a finite sentinel or raise your own clear error.","Sanitize the probe output: recursively replace NaN/inf with valid numbers or drop those keys before returning.","If using ffprobe, handle 'N/A'/'0/0' rate strings explicitly instead of letting float() propagate NaN/inf.","For mock probes in tests, generate payloads that satisfy the finite-number contract (no bools, no nan/inf)."],"exampleFix":"// before\nprobe = lambda p: {\"duration\": 5.0, \"has_audio\": True, \"fps\": float('inf')}\nrun_workflow(\"contract.json\", \"out/\", probe=probe)\n// after\nprobe = lambda p: {\"duration\": 5.0, \"audio_channels\": 2, \"fps\": 0.0}\nrun_workflow(\"contract.json\", \"out/\", probe=probe)","handlingStrategy":"type-guard","validationCode":"import math\n\ndef probe_payload_is_clean(measured: dict) -> bool:\n    def walk(v):\n        if isinstance(v, bool) or v is None:\n            return False\n        if isinstance(v, (int, float)):\n            return math.isfinite(v)\n        if isinstance(v, dict):\n            return all(walk(x) for x in v.values())\n        if isinstance(v, list):\n            return all(walk(x) for x in v)\n        return True\n    return isinstance(measured, dict) and walk(measured)\n\n# before run_workflow(..., probe=my_probe)\nassert probe_payload_is_clean(my_probe(path)), \"probe returned bool/non-finite evidence\"","typeGuard":"def is_finite_real(v) -> bool:\n    return isinstance(v, (int, float)) and not isinstance(v, bool) and math.isfinite(v)","tryCatchPattern":"try:\n    receipt = run_workflow(\"contract.json\", \"out/\", probe=my_probe)\nexcept ValueError as e:\n    if \"finite real values\" in str(e):\n        logger.error(\"probe emitted bool/NaN/inf: sanitize or fix the probe callable\")\n        receipt = run_workflow(\"contract.json\", \"out/\", probe=sanitize(my_probe))\n    else:\n        raise","preventionTips":["Never return booleans from a probe; encode flags numerically or omit them","Run every probe output through an isfinite check before returning it","Guard all divisions in probe math against zero denominators","Keep test doubles/probe stubs aligned with the finite-number contract"],"tags":["validation","nan","data-quality","media-processing"],"backgroundTag":"schema-validation-failed","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}