Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter caps the number of AI calls per rolling hour. Pure in-memory: a process restart resets the window, which is acceptable because the goal is to bound cost per running process — not to enforce a quota across a fleet (we run one agent worker per replica).
max <= 0 disables the limit (Allow always returns true).
func NewRateLimiter ¶
func NewRateLimiter(maxPerHour int) *RateLimiter
NewRateLimiter constructs a limiter with the configured per-hour cap.
func (*RateLimiter) Allow ¶
func (r *RateLimiter) Allow() bool
Allow returns true and records a use when the caller is under the per-hour cap, false otherwise. Thread-safe.
func (*RateLimiter) Stats ¶
func (r *RateLimiter) Stats() (bucket string, used, max int)
Stats returns the current hour bucket and how many calls have been allowed in it. Used by the admin status endpoint.
type ResultCache ¶
type ResultCache struct {
// contains filtered or unexported fields
}
ResultCache memoises AI findings by pattern_id so a recurring pattern inside one cache window does not pay for a repeat LLM call.
State is held in-memory and (best effort) mirrored to storage.Provider under config.AICacheBlobName so it survives restarts. A storage write failure logs but does not block the caller — the cache still works for the lifetime of the process.
func NewResultCache ¶
func NewResultCache(ttl time.Duration, store storage.Provider) *ResultCache
NewResultCache builds a cache with the configured TTL. ttl <= 0 disables caching (Get always misses, Put is a no-op).
store may be nil — in that case the cache is in-memory only.
func (*ResultCache) Flush ¶
func (c *ResultCache) Flush()
Flush wipes every entry and persists. Used by the admin endpoint.
func (*ResultCache) Get ¶
func (c *ResultCache) Get(patternID string) (*core.AIFinding, bool)
Get returns a cached finding when one exists and has not expired.
func (*ResultCache) Len ¶
func (c *ResultCache) Len() int
Len returns the number of live entries (including expired-but-not-evicted).
func (*ResultCache) Persist ¶
func (c *ResultCache) Persist() error
Persist writes the cache to storage. No-op when store is nil or the cache hasn't changed since the last persist.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package analyze contains the analyze-kind AI agent: operator- triggered, tool-using, single-incident investigation.
|
Package analyze contains the analyze-kind AI agent: operator- triggered, tool-using, single-incident investigation. |
|
tools
Package tools holds the read-only tool catalog exposed to the analyze-kind AI agent.
|
Package tools holds the read-only tool catalog exposed to the analyze-kind AI agent. |
|
Package detect contains the detect-kind AI agent: cheap, tool-free, single-call classification of unknown / spiking log patterns.
|
Package detect contains the detect-kind AI agent: cheap, tool-free, single-call classification of unknown / spiking log patterns. |
|
Package eino contains the Eino-backed chat model wrapper used by all AI agents in versus-incident.
|
Package eino contains the Eino-backed chat model wrapper used by all AI agents in versus-incident. |
|
Package prompt is a content-free helper for assembling multi-file system prompts.
|
Package prompt is a content-free helper for assembling multi-file system prompts. |
|
Package router dispatches AITasks to the right AIAgent and wraps each call with per-kind caching and per-kind rate limiting.
|
Package router dispatches AITasks to the right AIAgent and wraps each call with per-kind caching and per-kind rate limiting. |