{"record":{"id":"4d7e92f0f3dfc2ec","repo":"oraios/serena","slug":"memory-maintenance-template-not-found-at-template","errorCode":null,"errorMessage":"Memory maintenance template not found at {template_path}","messagePattern":"Memory maintenance template not found at (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/serena/memories/memory_manager.py","lineNumber":118,"sourceCode":"\n        Existing memory files are never overwritten; users may have customized them. To\n        refresh from the shipped template, delete the existing memory first.\n\n        :return: the bare name to reference the maintenance memory by (without the ``mem:``\n            prefix); either ``\"global/memory_maintenance\"`` or ``\"memory_maintenance\"``.\n        :raises FileNotFoundError: if the shipped template is missing on disk.\n        :raises AssertionError: if this manager has no associated project directory.\n        \"\"\"\n        global_name = f\"{self.GLOBAL_TOPIC}/{self.MEMORY_MAINTENANCE_NAME}\"\n        if self.get_memory_file_path(global_name).exists():\n            return global_name\n        if self.get_memory_file_path(self.MEMORY_MAINTENANCE_NAME).exists():\n            return self.MEMORY_MAINTENANCE_NAME\n\n        # seed a project copy from the shipped template\n        template_path = self._MEMORY_MAINTENANCE_TEMPLATE_PATH\n        if not template_path.exists():\n            raise FileNotFoundError(f\"Memory maintenance template not found at {template_path}\")\n        content = template_path.read_text(encoding=self._encoding)\n        self.save_memory(self.MEMORY_MAINTENANCE_NAME, content, is_tool_context=False)\n        return self.MEMORY_MAINTENANCE_NAME\n\n    def rename_references_to_memory(self, content: str, old_name: str, new_name: str) -> tuple[str, int]:\n        r\"\"\"\n        Replaces all occurrences of a memory reference (e.g. ``mem:foo``) in ``content`` with\n        the reference to ``new_name``.\n\n        Matches only references whose name is exactly ``old_name``: the match must not be\n        embedded in a longer memory name. A memory name consists of the character class\n        ``[A-Za-z0-9_\\\\-/]`` (alphanumerics, underscore, hyphen, slash for topic separation),\n        which determines the boundary of the match. The surrounding delimiters (backticks,\n        quotes, parentheses, whitespace, etc.) are intentionally unconstrained.\n\n        :param content: the text to search through\n        :param old_name: the memory name being renamed away from (without the ``mem:`` prefix)\n        :param new_name: the memory name being renamed to (without the ``mem:`` prefix)","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/memories/memory_manager.py#L100-L136","documentation":"ensure_memory_maintenance_memory seeds a project-level memory-maintenance memory by copying a template shipped with the serena package. If the template file at _MEMORY_MAINTENANCE_TEMPLATE_PATH does not exist on disk, FileNotFoundError is raised. This indicates the installation is broken or the template was removed.","triggerScenarios":"Calling ensure_memory_maintenance_memory (directly or via initialize/apply) when the project has no memory-maintenance memory yet AND the bundled template file is missing from the installed package.","commonSituations":"Partial/broken pip install or wheel build that excluded the template resource; manually deleted files inside the installed serena package; running from a source checkout where the template was moved or not committed; packaging tools (e.g. setuptools without package-data config) that skipped non-.py resources.","solutions":["Reinstall serena cleanly: pip uninstall serena && pip install --force-reinstall serena (or pip install -e . from a fresh checkout).","Verify the template exists at the path in _MEMORY_MAINTENANCE_TEMPLATE_PATH inside site-packages; if missing, the package data was not shipped.","If installing from source, ensure the template file is present in src/serena/memories/ and that package-data/include patterns cover .md resources.","As a workaround, pre-create the memory-maintenance memory in the project (.serena/memories/) so the template copy path is skipped."],"exampleFix":"// before\npip install serena  # broken wheel without template resources\n// after\npip uninstall -y serena\npip install --force-reinstall serena\n# verify:\npython -c \"import serena.memories, pathlib; print(pathlib.Path(serena.memories.__file__).parent)\"","handlingStrategy":"fallback","validationCode":"from pathlib import Path\ntemplate = manager._MEMORY_MAINTENANCE_TEMPLATE_PATH\nif not template.exists():\n    raise RuntimeError(f\"serena install broken: missing {template}; reinstall the package\")","typeGuard":"def template_available(manager) -> bool:\n    return bool(getattr(manager, \"_MEMORY_MAINTENANCE_TEMPLATE_PATH\", None)\n                and manager._MEMORY_MAINTENANCE_TEMPLATE_PATH.exists())","tryCatchPattern":"try:\n    name = manager.ensure_memory_maintenance_memory()\nexcept FileNotFoundError:\n    log.warning(\"maintenance template missing; skipping seeding\")\n    name = None","preventionTips":["Reinstall/verify the package after upgrades (pip check, force-reinstall)","Ensure packaging includes non-.py resources (.md templates)","Verify template presence in CI before deploying"],"tags":["python","missing-file","packaging","installation"],"backgroundTag":"missing-template-resource","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}