{"record":{"id":"a999d1862a3ae56e","repo":"affaan-m/ECC","slug":"label-contains-a-boolean-numeric-value","errorCode":null,"errorMessage":"{label} contains a boolean numeric value","messagePattern":"(.+?) contains a boolean numeric value","errorType":"validation","errorClass":"ContractError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/contract.py","lineNumber":39,"sourceCode":"\ndef _is_finite_real(value: Any) -> bool:\n    return isinstance(value, (int, float)) and not isinstance(value, bool) and math.isfinite(value)\n\n\ndef _validate_media_time(value: Any, source_duration: Any, *, label: str) -> None:\n    if not _is_finite_real(source_duration):\n        raise ContractError(f\"{label} has an invalid finite source duration\")\n    source_duration = cast(float, source_duration)\n    if float(source_duration) <= 0:\n        raise ContractError(f\"{label} has an invalid finite source duration\")\n    if (not _is_finite_real(value) or float(value) < 0\n            or float(value) > float(source_duration)):\n        raise ContractError(f\"{label} is outside its source duration\")\n\n\ndef _validate_numeric_evidence(value: Any, *, label: str) -> None:\n    if isinstance(value, bool):\n        raise ContractError(f\"{label} contains a boolean numeric value\")\n    if isinstance(value, (int, float)):\n        if not math.isfinite(value):\n            raise ContractError(f\"{label} contains a non-finite numeric value\")\n    elif isinstance(value, dict):\n        for nested in value.values():\n            _validate_numeric_evidence(nested, label=label)\n    elif isinstance(value, list):\n        for nested in value:\n            _validate_numeric_evidence(nested, label=label)\n\n\ndef _validate_probe_evidence(probe: Any, source_duration: float, *, label: str) -> None:\n    if not isinstance(probe, dict):\n        raise ContractError(f\"{label} lacks probe evidence\")\n    _validate_numeric_evidence(probe, label=label)\n    if probe.get(\"duration\") != source_duration:\n        raise ContractError(f\"{label} probe duration is not bound to source duration\")\n    for field in (\"sample_times\", \"scene_changes\"):","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/contract.py#L21-L57","documentation":"_validate_numeric_evidence rejects boolean values used where numbers are expected. In Python, bool is a subclass of int, so True would silently pass numeric checks; this explicit check prevents booleans from posing as numeric evidence in probe documents.","triggerScenarios":"validate_genre_specs or probe evidence containing numeric fields set to true/false — e.g. \"duration\": true, nested dicts/lists of evidence containing booleans. The function recurses into dicts and lists, so any nested bool triggers it.","commonSituations":"YAML-authored specs where yes/no become booleans, authors using true as a placeholder for 1, template documents with unfinished boolean toggles inside numeric blocks.","solutions":["Replace boolean values in numeric fields with actual numbers (1/0) in the source document.","If the field is genuinely a flag, move it outside the numeric-evidence structure.","Author YAML with explicit numbers (duration: 1) and quote values that must stay strings/bools.","Add a pre-save lint that rejects bools inside numeric evidence sections."],"exampleFix":"// before\n\"duration\": true\n// after\n\"duration\": 1","handlingStrategy":"type-guard","validationCode":"def no_bools(node) -> bool:\n    if isinstance(node, bool): return False\n    if isinstance(node, dict): return all(no_bools(v) for v in node.values())\n    if isinstance(node, list): return all(no_bools(v) for v in node)\n    return True","typeGuard":"def is_real_number(v) -> bool:\n    return isinstance(v, (int, float)) and not isinstance(v, bool)","tryCatchPattern":"try:\n    validate_genre_specs(spec)\nexcept ContractError as e:\n    if 'boolean numeric value' in str(e):\n        fix_bool_numerics(spec)  # map True/False to 1/0 in numeric fields\n    else:\n        raise","preventionTips":["Never use true/false as placeholders for 1/0 in evidence fields","Remember bool is a subclass of int in Python — always check bool first","When authoring YAML, quote values that must not coerce to booleans","Lint numeric-evidence sections for booleans before saving"],"tags":["python","validation","types"],"backgroundTag":"type-mismatch","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"}