rohitg00/ai-engineering-from-scratch · error · ValueError
invalidationRule is required
Error message
invalidationRule is required
What it means
Error "invalidationRule is required" thrown in rohitg00/ai-engineering-from-scratch.
Source
Thrown at certifications/claude/lessons/04-context-knowledge-memory-and-caching/code/main.py:74
errors.append(f"cached source is not active, stable, and eligible: {identifier}")
elif source.get("sensitivity") == "restricted":
errors.append(f"restricted source cannot enter cached prefix: {identifier}")
budget = registry.get("promptBudget")
if not isinstance(budget, dict) or not isinstance(budget.get("maximumTokens"), int):
errors.append("promptBudget is invalid")
else:
used = sum(value for key, value in budget.items() if key != "maximumTokens" and isinstance(value, int))
if used > budget["maximumTokens"]:
errors.append("prompt budget exceeds maximumTokens")
if not str(registry.get("invalidationRule", "")).strip():
errors.append("invalidationRule is required")
return errors
def build_context_plan(registry: dict[str, Any]) -> dict[str, Any]:
errors = validate_registry(registry)
if errors:
raise ValueError("; ".join(errors))
cached = set(registry["cachedPrefixSourceIds"])
return {
"cachedPrefix": [source["id"] for source in registry["sources"] if source["id"] in cached],
"dynamicContext": [source["id"] for source in registry["sources"] if source["status"] == "active" and source["id"] not in cached],
"retired": [source["id"] for source in registry["sources"] if source["status"] != "active"],
"budgetRemaining": registry["promptBudget"]["maximumTokens"] - sum(value for key, value in registry["promptBudget"].items() if key != "maximumTokens"),
}
def _iso_date(value: Any) -> bool:
try:
date.fromisoformat(value)
return isinstance(value, str)
except (TypeError, ValueError):
return False
def load_registry(path: Path) -> dict[str, Any]:View on GitHub (pinned to 39ea8a1c6d)
When it happens
Trigger: Thrown at certifications/claude/lessons/04-context-knowledge-memory-and-caching/code/main.py:74 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26).
Data as JSON: /api/errors/c7c223ba5001c0b6.
Report an issue: GitHub.