{"record":{"id":"1a4a4ea7f86791c3","repo":"rohitg00/ai-engineering-from-scratch","slug":"unknown-hook-topic-topic","errorCode":null,"errorMessage":"unknown hook topic: {topic}","messagePattern":"unknown hook topic: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phases/19-capstone-projects/20-agent-harness-loop-contract/code/main.py","lineNumber":126,"sourceCode":"    state: State\n    payload: dict\n\n\n@dataclass\nclass SessionResult:\n    state: State\n    reason: str\n    steps: list[Step]\n    events: list[Event]\n\n\nclass HookRegistry:\n    def __init__(self) -> None:\n        self._subs: dict[str, list[Callable[[dict], Any]]] = {t: [] for t in HOOK_TOPICS}\n\n    def on(self, topic: str, fn: Callable[[dict], Any]) -> None:\n        if topic not in self._subs:\n            raise ValueError(f\"unknown hook topic: {topic}\")\n        self._subs[topic].append(fn)\n\n    def fire(self, topic: str, payload: dict) -> list[Any]:\n        results = []\n        for fn in self._subs[topic]:\n            results.append(fn(payload))\n        return results\n\n\nPlanner = Callable[[str, list[Step]], list[Step]]\n\n\ndef _default_planner(goal: str, history: list[Step]) -> list[Step]:\n    \"\"\"Deterministic stand-in planner. Returns a fixed three-step plan.\"\"\"\n    if history:\n        return []\n    return [\n        Step(id=1, description=f\"interpret goal: {goal}\", requires_tool=False),","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/19-capstone-projects/20-agent-harness-loop-contract/code/main.py#L108-L144","documentation":"Subscription guard in HookRegistry.on: the topic string is not one of the predefined HOOK_TOPICS the registry was initialized with. Because fire() dispatches by topic with no listeners otherwise, a typo'd topic would silently swallow hook events, so misregistration is rejected immediately.","triggerScenarios":"Thrown at phases/19-capstone-projects/20-agent-harness-loop-contract/code/main.py:126 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Subscribe using one of the HOOK_TOPICS constants","Check for typos and casing in the topic string","Add genuinely new topics to HOOK_TOPICS explicitly rather than passing ad-hoc strings","Use an enum or constants module for topics at call sites"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}