{"record":{"id":"c7c223ba5001c0b6","repo":"rohitg00/ai-engineering-from-scratch","slug":"invalidationrule-is-required","errorCode":null,"errorMessage":"invalidationRule is required","messagePattern":"invalidationRule is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"certifications/claude/lessons/04-context-knowledge-memory-and-caching/code/main.py","lineNumber":74,"sourceCode":"                errors.append(f\"cached source is not active, stable, and eligible: {identifier}\")\n            elif source.get(\"sensitivity\") == \"restricted\":\n                errors.append(f\"restricted source cannot enter cached prefix: {identifier}\")\n    budget = registry.get(\"promptBudget\")\n    if not isinstance(budget, dict) or not isinstance(budget.get(\"maximumTokens\"), int):\n        errors.append(\"promptBudget is invalid\")\n    else:\n        used = sum(value for key, value in budget.items() if key != \"maximumTokens\" and isinstance(value, int))\n        if used > budget[\"maximumTokens\"]:\n            errors.append(\"prompt budget exceeds maximumTokens\")\n    if not str(registry.get(\"invalidationRule\", \"\")).strip():\n        errors.append(\"invalidationRule is required\")\n    return errors\n\n\ndef build_context_plan(registry: dict[str, Any]) -> dict[str, Any]:\n    errors = validate_registry(registry)\n    if errors:\n        raise ValueError(\"; \".join(errors))\n    cached = set(registry[\"cachedPrefixSourceIds\"])\n    return {\n        \"cachedPrefix\": [source[\"id\"] for source in registry[\"sources\"] if source[\"id\"] in cached],\n        \"dynamicContext\": [source[\"id\"] for source in registry[\"sources\"] if source[\"status\"] == \"active\" and source[\"id\"] not in cached],\n        \"retired\": [source[\"id\"] for source in registry[\"sources\"] if source[\"status\"] != \"active\"],\n        \"budgetRemaining\": registry[\"promptBudget\"][\"maximumTokens\"] - sum(value for key, value in registry[\"promptBudget\"].items() if key != \"maximumTokens\"),\n    }\n\n\ndef _iso_date(value: Any) -> bool:\n    try:\n        date.fromisoformat(value)\n        return isinstance(value, str)\n    except (TypeError, ValueError):\n        return False\n\n\ndef load_registry(path: Path) -> dict[str, Any]:","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/certifications/claude/lessons/04-context-knowledge-memory-and-caching/code/main.py#L56-L92","documentation":"Error \"invalidationRule is required\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at certifications/claude/lessons/04-context-knowledge-memory-and-caching/code/main.py:74 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}