{"record":{"id":"5aaec851c2fe4756","repo":"HKUDS/Vibe-Trading","slug":"run-directory-not-found-rd-name","errorCode":null,"errorMessage":"Run directory not found: {rd.name}","messagePattern":"Run directory not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"agent/src/swarm/store.py","lineNumber":216,"sourceCode":"            except (OSError, ValueError) as exc:\n                last = exc\n                if attempt < len(_REPLACE_BACKOFF):\n                    time.sleep(_REPLACE_BACKOFF[attempt])\n        assert last is not None  # loop body sets `last` or returns\n        raise type(last)(redact_internal_paths(str(last))) from None\n\n    def update_run(self, run: SwarmRun) -> None:\n        \"\"\"Atomically update run state.\n\n        Args:\n            run: Updated SwarmRun instance.\n\n        Raises:\n            FileNotFoundError: If the run directory does not exist.\n        \"\"\"\n        rd = self.run_dir(run.id)\n        if not rd.exists():\n            raise FileNotFoundError(f\"Run directory not found: {rd.name}\")\n        self._atomic_write(rd / \"run.json\", run.model_dump_json(indent=2))\n\n    def list_runs(self, limit: int = 50) -> list[SwarmRun]:\n        \"\"\"List all runs sorted by created_at descending.\n\n        Args:\n            limit: Maximum number of runs to return.\n\n        Returns:\n            List of SwarmRun instances.\n        \"\"\"\n        if not self.base_dir.exists():\n            return []\n\n        runs: list[SwarmRun] = []\n        for entry in self.base_dir.iterdir():\n            if not entry.is_dir():\n                continue","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/swarm/store.py#L198-L234","documentation":"update_run resolves the run directory via run_dir(run.id) and raises FileNotFoundError when it does not exist on disk — i.e. the run was never created (create_run not called) or its directory was deleted/moved.","triggerScenarios":"Calling update_run on a SwarmRun constructed in memory without create_run; resuming after someone wiped the runs directory; a run id from a different base_dir.","commonSituations":"Resume/recovery flows after manual cleanup or a different SWARM store root; tests that build run objects without persisting them first.","solutions":["Call create_run(run) before any update_run/append_event","Verify the store's base_dir matches where runs were created","If the directory was deleted intentionally, start a new run instead of updating"],"exampleFix":"# before\nstore.update_run(run)  # run never created\n# after\npath = store.create_run(run)\nstore.update_run(run)","handlingStrategy":"validation","validationCode":"if not store.run_dir(run.id).exists():\n    store.create_run(run)\nstore.update_run(run)","typeGuard":null,"tryCatchPattern":"try:\n    store.update_run(run)\nexcept FileNotFoundError as e:\n    if 'Run directory not found' in str(e):\n        store.create_run(run); store.update_run(run)\n    else: raise","preventionTips":["Always create_run before update/append flows","Confirm base_dir consistency across processes","Guard resume logic with an existence check"],"tags":["python","file-not-found","swarm","persistence"],"backgroundTag":"file-not-found","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}