perf: cache permitted tools per API key #53
No reviewers
Labels
No labels
P1
P2
P3
PHP
agent-ready
bug
clotho
discovery
docs
refactor
review
security
testing
athena
athena-gemini
audit
clotho
clotho-gemini
codex
darbs-claude
security
wiki
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: core/php-agentic#53
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "perf/cache-permitted-tools-per-api-key"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
AgentToolRegistry::forApiKey()usingCache::remember()with a 1-hour TTL, eliminating the O(n) filter on every request (PERF-002)flushCacheForApiKey(int|string $id)for explicit invalidation and aCACHE_TTLconstantAgentApiKeyService::updatePermissions()andrevoke()so permission changes take effect immediatelytests/Unit/AgentToolRegistryTest.phpcovering cache hit/miss, per-key isolation, scope filtering, TTL constant, and flush behaviourTest plan
./vendor/bin/pest --filter=AgentToolRegistrypasses (all 14 new unit tests)./vendor/bin/pestfull suite passesagent_tool_registry:api_key:{id}in Redis/cache storeAgentApiKeyService::updatePermissions()is calledAgentApiKeyService::revoke()is calledCloses #24
🤖 Generated with Claude Code
Cache the list of permitted tool names in `AgentToolRegistry::forApiKey()` using a 1-hour TTL to avoid O(n) filtering on every request (PERF-002). - Add `Cache::remember()` in `forApiKey()` storing tool names keyed by API key ID (`agent_tool_registry:api_key:{id}`) - Add `flushCacheForApiKey(int|string $id)` for explicit invalidation - Add `CACHE_TTL` constant (3600 s) for easy tuning - Invalidate cache in `AgentApiKeyService::updatePermissions()` and `revoke()` so permission changes take effect immediately - Add `tests/Unit/AgentToolRegistryTest.php` covering cache hit/miss, per-key isolation, scope filtering, TTL constant, and flush behaviour Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>