{"record":{"id":"a7f6c97a66169af7","repo":"rohitg00/ai-engineering-from-scratch","slug":"plateau-window-must-be-1","errorCode":null,"errorMessage":"plateau_window must be >= 1","messagePattern":"plateau_window must be >= 1","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phases/19-capstone-projects/55-critic-loop/code/main.py","lineNumber":146,"sourceCode":"        }\n\n\nclass CriticLoop:\n    \"\"\"Drives critic -> reviser -> convergence-check until a stop condition fires.\"\"\"\n\n    def __init__(\n        self,\n        critic: Critic,\n        reviser: Reviser,\n        max_rounds: int = 5,\n        target_score: float = 8.0,\n        plateau_epsilon: float = 0.1,\n        plateau_window: int = 2,\n    ) -> None:\n        if max_rounds < 1:\n            raise ValueError(\"max_rounds must be >= 1\")\n        if plateau_window < 1:\n            raise ValueError(\"plateau_window must be >= 1\")\n        self.critic = critic\n        self.reviser = reviser\n        self.max_rounds = max_rounds\n        self.target_score = target_score\n        self.plateau_epsilon = plateau_epsilon\n        self.plateau_window = plateau_window\n\n    def _target_met(self, critique: Critique) -> bool:\n        return all(critique.scores.get(d, 0.0) >= self.target_score for d in DIMENSIONS)\n\n    def _plateau(self, trace: list[LoopTrace]) -> bool:\n        if len(trace) < self.plateau_window + 1:\n            return False\n        recent = trace[-(self.plateau_window + 1):]\n        for i in range(1, len(recent)):\n            if recent[i].mean - recent[i - 1].mean > self.plateau_epsilon:\n                return False\n        return True","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/19-capstone-projects/55-critic-loop/code/main.py#L128-L164","documentation":"Error \"plateau_window must be >= 1\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/19-capstone-projects/55-critic-loop/code/main.py:146 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"}