Context
The agentic framework's decision cache is a hot-path component that provides O(1) reuse of ABAC policy decisions, but the entire deepintshield_server/framework/agentic/ package currently has no *_test.go files. This makes the cache a high-value, self-contained target for a first contribution: the public surface is small and the behavior is easy to assert without external services.
The implementation is:
type DecisionCache struct { ... }
func NewDecisionCache(maxSize int) *DecisionCache
func (c *DecisionCache) Get(key string) (Decision, bool)
func (c *DecisionCache) Put(key string, decision Decision, ttl time.Duration)
func (c *DecisionCache) InvalidateTenant(tenant string)
func (c *DecisionCache) Stats() CacheStats
What to do
Create deepintshield_server/framework/agentic/decision_cache_test.go with table-driven tests covering:
- Hit / miss:
Put then Get the same key returns the stored Decision and ok=true; an unknown key returns ok=false.
- TTL expiry: an entry stored with a short TTL is no longer returned after it expires.
- Eviction: once
maxSize is exceeded, the oldest/least-recently-used entry is dropped (verify it misses while newer entries hit).
InvalidateTenant: entries for a given tenant are removed while other tenants' entries survive.
Stats: hit/miss counters reported by Stats() reflect the operations performed.
- Concurrency: run many goroutines doing
Get/Put under go test -race with no data races or panics.
- Edge cases: zero/negative
maxSize, empty key.
Acceptance criteria
File pointers
- Implementation:
deepintshield_server/framework/agentic/decision_cache.go (NewDecisionCache:33, Get:49, Put:69, InvalidateTenant:85, Stats:116)
- How the cache is used:
deepintshield_server/framework/agentic/decide.go (Decide at line ~285)
- Test-style reference:
deepintshield_server/plugins/guardrails/request_guardrails_test.go
Context
The agentic framework's decision cache is a hot-path component that provides O(1) reuse of ABAC policy decisions, but the entire
deepintshield_server/framework/agentic/package currently has no*_test.gofiles. This makes the cache a high-value, self-contained target for a first contribution: the public surface is small and the behavior is easy to assert without external services.The implementation is:
What to do
Create
deepintshield_server/framework/agentic/decision_cache_test.gowith table-driven tests covering:PutthenGetthe same key returns the storedDecisionandok=true; an unknown key returnsok=false.maxSizeis exceeded, the oldest/least-recently-used entry is dropped (verify it misses while newer entries hit).InvalidateTenant: entries for a given tenant are removed while other tenants' entries survive.Stats: hit/miss counters reported byStats()reflect the operations performed.Get/Putundergo test -racewith no data races or panics.maxSize, empty key.Acceptance criteria
deepintshield_server/framework/agentic/decision_cache_test.go.go test -race ./agentic/...(run fromdeepintshield_server/framework) passes.CONTRIBUTING.md.File pointers
deepintshield_server/framework/agentic/decision_cache.go(NewDecisionCache:33, Get:49, Put:69, InvalidateTenant:85, Stats:116)deepintshield_server/framework/agentic/decide.go(Decide at line ~285)deepintshield_server/plugins/guardrails/request_guardrails_test.go