{"record":{"id":"d98d43a01e256ef8","repo":"affaan-m/ECC","slug":"historical-request-evidence-required","errorCode":null,"errorMessage":"historical request evidence required","messagePattern":"historical request evidence required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/integration.py","lineNumber":300,"sourceCode":"    result = {}\n    for item in items:\n        _object(item, {\"id\", \"media\", \"media_frames\", \"fps\", \"origin\", \"relationship\",\n                       \"source_sha256\", \"compiled_input_sha256\", \"review_status\", \"generation_receipt\"})\n        name = _text(item[\"id\"])\n        if name in result:\n            raise ValueError(\"candidate ids must be unique\")\n        _artifact(item[\"media\"])\n        _integer(item[\"media_frames\"], 1)\n        _rate(item[\"fps\"])\n        if item[\"origin\"] != \"provider_generated\" or item[\"relationship\"] != \"generated_variation\":\n            raise ValueError(\"a generated candidate cannot claim original-source identity\")\n        if item[\"source_sha256\"] != source_hash or item[\"compiled_input_sha256\"] != input_hash:\n            raise ValueError(\"candidate is bound to a different source or input\")\n        if item[\"review_status\"] not in (\"pending\", \"rejected\", \"approved\"):\n            raise ValueError(\"explicit candidate review state required\")\n        evidence = _artifact(item[\"generation_receipt\"], parse_json=True)\n        if not isinstance(evidence, dict) or not isinstance(evidence.get(\"request_id\"), str):\n            raise ValueError(\"historical request evidence required\")\n        _text(evidence[\"request_id\"])\n        expected = {\"source_sha256\": source_hash, \"compiled_input_sha256\": input_hash,\n                    \"candidate_sha256\": item[\"media\"][\"sha256\"], \"source_url\": source_url}\n        if any(evidence.get(key) != value for key, value in expected.items()):\n            raise ValueError(\"historical evidence does not bind the candidate source/input/bytes\")\n        result[name] = item\n    return result\n\n\ndef _inserts(items: list, candidates: dict, config: dict, input_hash: str, edit_hash: str) -> None:\n    occupied = []\n    for item in items:\n        _object(item, {\"candidate_id\", \"candidate_range\", \"timeline_range\", \"retime\", \"approval_file\"})\n        candidate = candidates.get(_text(item[\"candidate_id\"]))\n        if candidate is None or candidate[\"review_status\"] != \"approved\":\n            raise ValueError(\"insert requires an approved, resolved candidate\")\n        target = _range(item[\"timeline_range\"], config[\"baseline\"][\"timeline_range\"])\n        source = _range(item[\"candidate_range\"], [0, candidate[\"media_frames\"]])","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/integration.py#L282-L318","documentation":"Each candidate must include a 'generation_receipt' artifact that parses as JSON and contains a string 'request_id'. This receipt is the historical evidence tying the candidate to an actual provider generation request; without it TasteForge cannot audit where the footage came from and raises this error.","triggerScenarios":"Omitting the generation_receipt field, passing a non-JSON artifact path, or providing a receipt JSON whose top level is not an object or lacks a string 'request_id'.","commonSituations":"Hand-building candidates without running the provider (synthetic/test entries); receipts saved in a legacy format without request_id; receipt files truncated or corrupted on disk.","solutions":["Attach the original provider generation receipt JSON (with a string request_id) to each candidate","Re-export the candidate from the generation pipeline so the receipt is included and well-formed","Validate the receipt parses as a JSON object with a non-empty request_id before calling build_application_bundle"],"exampleFix":"// before\n{\"id\": \"cand-2\", \"generation_receipt\": {\"ts\": 123}}\n// after\n{\"id\": \"cand-2\", \"generation_receipt\": {\"request_id\": \"req_9f3a\", \"ts\": 123}}","handlingStrategy":"validation","validationCode":"function assertReceipt(c) {\n  const r = c.generation_receipt;\n  if (typeof r !== \"object\" || r === null || typeof r.request_id !== \"string\" || !r.request_id)\n    throw new Error(`candidate ${c.id} lacks valid generation receipt`);\n}","typeGuard":"function hasValidReceipt(c) {\n  const r = c?.generation_receipt;\n  return typeof r === \"object\" && r !== null && typeof r.request_id === \"string\";\n}","tryCatchPattern":"try {\n  buildApplicationBundle(cfg);\n} catch (e) {\n  if (e.message.includes(\"historical request evidence required\")) {\n    await attachReceipts(cfg.candidates); // fetch from generation store by media hash\n    return buildApplicationBundle(cfg);\n  }\n  throw e;\n}","preventionTips":["Persist the provider receipt at generation time, never as an afterthought","Validate receipts parse as JSON objects with a request_id when archiving candidates","Keep receipts and media in the same directory/archive so they travel together"],"tags":["audit","receipt","json"],"backgroundTag":"missing-required-argument","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"}