- 
                Notifications
    You must be signed in to change notification settings 
- Fork 75
[Server] bugfix: Cache discovery is unavailable #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| Hey @okxaas, thanks for reaching out - not sure I understand how you ran into an error, but I still this change makes sense 👍 See #115 and especially #116 for what I changed to provide more insights. Anyhow, like i wrote, makes sense still to me, but you need to address this one as well: php-sdk/src/Capability/Discovery/Discoverer.php Lines 92 to 101 in 6100ffc 
 cc @xentixar any thoughts on this? | 
| Hey @chr-hertel, with discovery caching enabled, the system was unable to utilize the cached content during actual runtime. Although the cache files were generated, the cached content couldn't be accessed. The issue was resolved after adding $registry->setDiscoveryState($discoveryState) to the performDiscovery method, which allowed the system to properly use the cached content. | 
| Hey @chr-hertel, good catch! You're right - the PR is incomplete. The refactoring removes  Line 92-101 should change from: if (empty($absolutePaths)) {
    $this->logger->warning('No valid discovery directories found to scan.', [
        'configured_paths' => $directories,
        'base_path' => $basePath,
    ]);
    $emptyState = new DiscoveryState();
    $this->registry->setDiscoveryState($emptyState);
    return $emptyState;
}To: if (empty($absolutePaths)) {
    $this->logger->warning('No valid discovery directories found to scan.', [
        'configured_paths' => $directories,
        'base_path' => $basePath,
    ]);
    return new DiscoveryState();
}This way,  @okxaas - Can you update line 99 to complete the refactoring? | 
| hi, This issue occurs in  //  CachedDiscoverer.php
        $discoveryState = $this->discoverer->discover($basePath, $directories, $excludeDirs);
        $this->cache->set($cacheKey, $discoveryState);
        return $discoveryState;// Discoverer.php
        $discoveryState = new DiscoveryState($tools, $resources, $prompts, $resourceTemplates);
        $this->registry->setDiscoveryState($discoveryState);
        return $discoveryState; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood & makes sense, still needs the patch here:
php-sdk/src/Capability/Discovery/Discoverer.php
Lines 92 to 101 in 6100ffc
| if (empty($absolutePaths)) { | |
| $this->logger->warning('No valid discovery directories found to scan.', [ | |
| 'configured_paths' => $directories, | |
| 'base_path' => $basePath, | |
| ]); | |
| $emptyState = new DiscoveryState(); | |
| $this->registry->setDiscoveryState($emptyState); | |
| return $emptyState; | 
Thanks already! :) 👍
Changes
Moved discovery state registration logic from the
Discovererclass to theBuilderclass.Specific Changes
Discoverer.php: Removed the
setDiscoveryState()call, making thediscover()method solely responsible for returning aDiscoveryStateobject.Builder.php: Added handling and registration of the returned
DiscoveryStateobject to theperformDiscovery()method.Why This Refactor Was Needed
Separation of Concerns
Discoverercould not return results in a cached state and did not call $registry->setDiscoveryState.Discovereris solely responsible for discovering and returning results, whileBuildercoordinates the entire build process.Impact