fix: resolve RedisCache array offset error and improve discovery diagnostics

- Fix RedisCache driver to handle MGET failures gracefully with fallback
- Add comprehensive discovery context comparison debug tools
- Identify root cause: WEB context discovery missing 166 items vs CLI
- WEB context missing RequestFactory class entirely (52 vs 69 commands)
- Improved exception handling with detailed binding diagnostics
This commit is contained in:
2025-09-12 20:05:18 +02:00
parent 8040d3e7a5
commit e30753ba0e
46990 changed files with 10789682 additions and 89639 deletions

View File

@@ -41,8 +41,10 @@ final class DiscoveryCacheManager
private const string CACHE_PREFIX = 'discovery:';
private const int DEFAULT_TTL_HOURS = 24;
/** @var array<string, array<string, mixed>> */
private array $cacheMetrics = [];
/** @var array<string, array<string, mixed>> */
private array $accessPatterns = [];
private CacheLevel $currentLevel = CacheLevel::NORMAL;
@@ -224,9 +226,12 @@ final class DiscoveryCacheManager
/**
* Get enhanced cache health status with memory awareness
*
* @return array<string, mixed>
*/
public function getHealthStatus(): array
{
/** @var array<string, mixed> */
$baseStatus = [
'cache_driver' => get_class($this->cache),
'ttl_hours' => $this->ttlHours,
@@ -275,6 +280,8 @@ final class DiscoveryCacheManager
/**
* Perform memory pressure management
*
* @return array<string, mixed>
*/
public function performMemoryPressureManagement(): array
{
@@ -283,6 +290,7 @@ final class DiscoveryCacheManager
}
$memoryStatus = $this->memoryManager->getMemoryStatus('pressure_management');
/** @var array<int, string> */
$actions = [];
if ($memoryStatus->status === MemoryStatus::CRITICAL) {
@@ -430,6 +438,7 @@ final class DiscoveryCacheManager
// Emit compression event
$this->emitCompressionEvent($originalSize, $compressedSize, $compressionLevel);
/** @var array<string, mixed> */
return [
'__discovery_compressed__' => true,
'data' => $compressed,
@@ -531,6 +540,7 @@ final class DiscoveryCacheManager
$timeWindow = 3600; // 1 hour
$currentTime = $this->clock->time();
/** @var array<int, int> */
$recentAccesses = array_filter(
$pattern['access_history'],
fn ($timestamp) => ($currentTime - $timestamp) <= $timeWindow