feat(robot): NamespaceCacheMeta with python_executable, namespace caching, and weakref finalizer#583
Closed
feat(robot): NamespaceCacheMeta with python_executable, namespace caching, and weakref finalizer#583
Conversation
… caching, and weakref finalizer - Add `CacheSection.NAMESPACE` to data_cache.py for a dedicated namespace cache section - Add `NamespaceCacheMeta` dataclass to imports_manager.py with `python_executable: str` field to distinguish caches from different Python environments - Add `get_namespace_meta()`, `_get_namespace_doc_cached()`, and `_save_namespace_doc_cache()` methods to ImportsManager for Python-executable-aware namespace document caching - Update `get_libdoc_from_model()` and `get_resource_doc_from_document()` to use the new namespace cache (with python_executable) instead of the resource cache - Add `weakref.finalize` to `Namespace.__init__` with static `_finalize` method as an explicit cleanup marker and hook for future use - Add 10 regression tests for the new NamespaceCacheMeta and CacheSection.NAMESPACE Co-authored-by: d-biehl <7069968+d-biehl@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement weak reference finalizer for improved memory management
feat(robot): NamespaceCacheMeta with python_executable, namespace caching, and weakref finalizer
Mar 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Namespace-level resource docs were cached using only file path + mtime, meaning a Python environment change (e.g. switching venvs with same Python version) would silently serve stale cache. Adds a dedicated
NamespaceCacheMetathat includes the Python executable as a cache key, plus aweakref.finalizehook onNamespace.Changes
data_cache.pyCacheSection.NAMESPACE = "namespace"— dedicated cache section separate fromRESOURCE.imports_manager.pyNamespaceCacheMeta— new dataclass extending theRobotFileMetapattern withpython_executable: str:get_namespace_meta()— static factory that capturessys.executableat read time._get_namespace_doc_cached()/_save_namespace_doc_cache()— read/writeResourceDocunderCacheSection.NAMESPACE, validating the fullNamespaceCacheMetaincludingpython_executable.get_libdoc_from_model()andget_resource_doc_from_document()— switched from thepython_executable-unaware resource cache to the new namespace cache.namespace.pyweakref.finalize(self, Namespace._finalize, weakref.ref(imports_manager))in__init__(atexit=False). The static_finalizemethod documents the automatic cleanup contracts (event listeners viaWeakMethod, import entry sentinels via existingweakref.finalizeregistrations inImportsManager) and provides an explicit hook for future cleanup.Tests
CacheSection.NAMESPACE,NamespaceCacheMetaequality/differentiation bypython_executableandmtime_ns,filepath_basegeneration, andget_namespace_meta()behaviour on existing vs missing files.Original prompt
Delegate: "Delegate to cloud agent"
[Chronological Review: The conversation began with discussions about implementing a weak reference finalizer, followed by requests for documentation and commit messages related to recent changes. The user expressed concerns about variable resolution and namespace management, leading to deeper discussions about language server implementations and the handling of imports. The conversation evolved to address the need for caching mechanisms, diagnostics, and reference management for keywords and variables. The user emphasized the importance of regression tests and the overall architecture of the namespace and language server. The final phase involved the user requesting a detailed implementation plan and confirming readiness to start the implementation.][Intent Mapping:
[Technical Inventory:
[Code Archaeology:
[Progress Assessment:
[Context Validation: All critical information for continuation is captured, including user requests for implementation, documentation, and testing.]
[Recent Commands Analysis:
1. Conversation Overview: - Primary Objectives: The user requested the implementation of a weak reference finalizer, documentation of changes, commit messages, and discussions on namespace management and language server protocols. - Session Context: The conversation flowed from initial inquiries about weak references to detailed discussions on variable resolution, caching, and the architecture of the language server. - User Intent Evolution: The user moved from specific implementation requests to broader architectural considerations, culminating in a readiness to start the implementation.- Technical Foundation:
- Weak Reference Finalizer: Proposed to manage memory more efficiently.
- Namespace Management: Focus on variable resolution and caching strategies.
- Language Server Protocol (LSP): Considerations for handling imports and diagnostics.
- AST Model: Discussed for its memory implications.
- Codebase Status:
- No specific files were modified, but discussions centered around the architecture of the namespace and language server.
- Problem Resolution:
- Issues Encountere...
Created from VS Code.
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.