System Prompt System - Validators & Checkers¶
Files:
* cogs/system_prompt/data_validator.py
* cogs/system_prompt/cache_checker.py
This document covers the utility classes responsible for ensuring the integrity, consistency, and safety of the system prompt data and its cache. These are primarily developer tools used for debugging and maintaining the system.
SystemPromptDataValidator Class¶
This class is used to check the consistency of the stored JSON configuration files.
validate_config_consistency(self, guild_id, channel_id)¶
Checks if the configuration for a specific channel is well-formed.
- Checks Performed:
- Verifies that the main
{guild_id}.jsonfile exists. - Ensures the specified
channel_idexists within the file's channel configurations. - Checks for the presence of important metadata like the
updated_attimestamp. - Validates that the
modulesdata is in the correct format (a dictionary).
- Verifies that the main
- Returns: A dictionary containing a boolean
is_consistentflag and a list of any issues found.
fix_inconsistent_data(self, ...)¶
Attempts to automatically fix simple inconsistencies, such as adding a missing updated_at timestamp.
CacheConsistencyChecker Class¶
This class is a debugging tool used to verify that the in-memory cache is synchronized with the expected content generated from the configuration files.
check_cache_consistency(self, guild_id, channel_id, expected_content)¶
Compares the content currently in the cache for a channel against the "ground truth" content that should be there.
- Parameters:
expected_content(str): The prompt content as generated by a fresh run of theSystemPromptManager.get_effective_promptmethod.
- Returns: A dictionary detailing whether the cache is consistent and listing any discrepancies.
force_cache_refresh(self, ...)¶
A utility method to forcibly invalidate the cache for a specific channel, ensuring that the prompt will be regenerated from the configuration files on the next request.