semantics: complete DEF-to-region migration, fix regressions

- Convert legacy [DEF🆔Type] anchors to #region/#endregion across 329 files
- Reinstate _normalize_timestamp_value in sql_generator.py
- Fix MarkerLogger→logger migration in events.py (molecular CoT markers)
- Fix dataset_review orchestrator dependencies (_build_execution_snapshot)
- Fix config_manager stale-record deletion (moved to save path only)
- Add 77 missing [/DEF:] closers in 5 unbalanced test files
- Update assistant_chat.integration.test.js for #region format
- Apply molecular-cot-logging markers (REASON/REFLECT/EXPLORE) via logger.* methods
This commit is contained in:
2026-05-12 23:54:55 +03:00
parent fe8978f716
commit 306c5ae742
331 changed files with 9630 additions and 10312 deletions

View File

@@ -7,7 +7,7 @@ from .logger import belief_scope
# #region PluginLoader [C:3] [TYPE Class] [SEMANTICS plugin, loader, dynamic, import]
# @BRIEF Scans a specified directory for Python modules, dynamically loads them, and registers any classes that are valid implementations of the PluginBase interface.
# @LAYER Core
# @LAYER: Core
# @RELATION Depends on PluginBase. It is used by the main application to discover and manage available plugins.
class PluginLoader:
"""
@@ -15,10 +15,10 @@ class PluginLoader:
that inherit from PluginBase.
"""
# #region __init__ [TYPE Function]
# @BRIEF Initializes the PluginLoader with a directory to scan.
# @PRE plugin_dir is a valid directory path.
# @POST Plugins are loaded and registered.
# [DEF:__init__:Function]
# @PURPOSE: Initializes the PluginLoader with a directory to scan.
# @PRE: plugin_dir is a valid directory path.
# @POST: Plugins are loaded and registered.
# @PARAM: plugin_dir (str) - The directory containing plugin modules.
def __init__(self, plugin_dir: str):
with belief_scope("__init__"):
@@ -26,12 +26,12 @@ class PluginLoader:
self._plugins: Dict[str, PluginBase] = {}
self._plugin_configs: Dict[str, PluginConfig] = {}
self._load_plugins()
# #endregion __init__
# [/DEF:__init__:Function]
# #region _load_plugins [TYPE Function]
# @BRIEF Scans the plugin directory and loads all valid plugins.
# @PRE plugin_dir exists or can be created.
# @POST _load_module is called for each .py file.
# [DEF:_load_plugins:Function]
# @PURPOSE: Scans the plugin directory and loads all valid plugins.
# @PRE: plugin_dir exists or can be created.
# @POST: _load_module is called for each .py file.
def _load_plugins(self):
with belief_scope("_load_plugins"):
"""
@@ -61,12 +61,12 @@ class PluginLoader:
if filename.endswith(".py") and filename != "__init__.py":
module_name = filename[:-3]
self._load_module(module_name, file_path)
# #endregion _load_plugins
# [/DEF:_load_plugins:Function]
# #region _load_module [TYPE Function]
# @BRIEF Loads a single Python module and discovers PluginBase implementations.
# @PRE module_name and file_path are valid.
# @POST Plugin classes are instantiated and registered.
# [DEF:_load_module:Function]
# @PURPOSE: Loads a single Python module and discovers PluginBase implementations.
# @PRE: module_name and file_path are valid.
# @POST: Plugin classes are instantiated and registered.
# @PARAM: module_name (str) - The name of the module.
# @PARAM: file_path (str) - The path to the module file.
def _load_module(self, module_name: str, file_path: str):
@@ -102,12 +102,12 @@ class PluginLoader:
self._register_plugin(plugin_instance)
except Exception as e:
print(f"Error instantiating plugin {attribute_name} in {module_name}: {e}") # Replace with proper logging
# #endregion _load_module
# [/DEF:_load_module:Function]
# #region _register_plugin [TYPE Function]
# @BRIEF Registers a PluginBase instance and its configuration.
# @PRE plugin_instance is a valid implementation of PluginBase.
# @POST Plugin is added to _plugins and _plugin_configs.
# [DEF:_register_plugin:Function]
# @PURPOSE: Registers a PluginBase instance and its configuration.
# @PRE: plugin_instance is a valid implementation of PluginBase.
# @POST: Plugin is added to _plugins and _plugin_configs.
# @PARAM: plugin_instance (PluginBase) - The plugin instance to register.
def _register_plugin(self, plugin_instance: PluginBase):
with belief_scope("_register_plugin"):
@@ -143,13 +143,13 @@ class PluginLoader:
except Exception as e:
from ..core.logger import logger
logger.error(f"Error validating plugin '{plugin_instance.name}' (ID: {plugin_id}): {e}")
# #endregion _register_plugin
# [/DEF:_register_plugin:Function]
# #region get_plugin [TYPE Function]
# @BRIEF Retrieves a loaded plugin instance by its ID.
# @PRE plugin_id is a string.
# @POST Returns plugin instance or None.
# [DEF:get_plugin:Function]
# @PURPOSE: Retrieves a loaded plugin instance by its ID.
# @PRE: plugin_id is a string.
# @POST: Returns plugin instance or None.
# @PARAM: plugin_id (str) - The unique identifier of the plugin.
# @RETURN: Optional[PluginBase] - The plugin instance if found, otherwise None.
def get_plugin(self, plugin_id: str) -> Optional[PluginBase]:
@@ -158,25 +158,25 @@ class PluginLoader:
Returns a loaded plugin instance by its ID.
"""
return self._plugins.get(plugin_id)
# #endregion get_plugin
# [/DEF:get_plugin:Function]
# #region get_all_plugin_configs [TYPE Function]
# @BRIEF Returns a list of all registered plugin configurations.
# @PRE None.
# @POST Returns list of all PluginConfig objects.
# @RETURN List[PluginConfig] - A list of plugin configurations.
# [DEF:get_all_plugin_configs:Function]
# @PURPOSE: Returns a list of all registered plugin configurations.
# @PRE: None.
# @POST: Returns list of all PluginConfig objects.
# @RETURN: List[PluginConfig] - A list of plugin configurations.
def get_all_plugin_configs(self) -> List[PluginConfig]:
with belief_scope("get_all_plugin_configs"):
"""
Returns a list of all loaded plugin configurations.
"""
return list(self._plugin_configs.values())
# #endregion get_all_plugin_configs
# [/DEF:get_all_plugin_configs:Function]
# #region has_plugin [TYPE Function]
# @BRIEF Checks if a plugin with the given ID is registered.
# @PRE plugin_id is a string.
# @POST Returns True if plugin exists.
# [DEF:has_plugin:Function]
# @PURPOSE: Checks if a plugin with the given ID is registered.
# @PRE: plugin_id is a string.
# @POST: Returns True if plugin exists.
# @PARAM: plugin_id (str) - The unique identifier of the plugin.
# @RETURN: bool - True if the plugin is registered, False otherwise.
def has_plugin(self, plugin_id: str) -> bool:
@@ -185,6 +185,6 @@ class PluginLoader:
Checks if a plugin with the given ID is loaded.
"""
return plugin_id in self._plugins
# #endregion has_plugin
# [/DEF:has_plugin:Function]
# #endregion PluginLoader