Documentation
¶
Overview ¶
Package searchgate stores, per discovery scope, whether a discovery tool has been called — the signal the search-first gate (middleware.MCPWorkflowGateMiddleware) blocks query tools on. The scope key is chosen by the caller (middleware.PlatformContext.DiscoveryScopeKey): the authenticated user when known, else the session ID. It is an opaque string to this package. It exposes a small Store interface with an in-memory default and a PostgreSQL implementation (pkg/searchgate/postgres) so the signal is shared across replicas, the same way sessions and audit externalize.
The in-memory store is correct for single-replica / no-database deployments. A multi-replica deployment must use a shared store: otherwise a discovery recorded on one replica is invisible to a query handled by another, and the hard gate refuses the query even though the agent did call search (#789).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory Store. It is correct for single-replica or no-database deployments; it is NOT shared across replicas.
func NewMemoryStore ¶
func NewMemoryStore(ttl time.Duration) *MemoryStore
NewMemoryStore creates an in-memory discovery store. Entries expire ttl after the most recent MarkDiscovered.
func (*MemoryStore) Cleanup ¶
func (s *MemoryStore) Cleanup(_ context.Context) error
Cleanup removes expired entries.
func (*MemoryStore) Close ¶
func (*MemoryStore) Close() error
Close is a no-op for the in-memory store.
func (*MemoryStore) HasDiscovered ¶
HasDiscovered reports whether the scope has a live discovery record.
func (*MemoryStore) MarkDiscovered ¶
func (s *MemoryStore) MarkDiscovered(_ context.Context, scopeKey string) error
MarkDiscovered records discovery for the scope, (re)setting its expiry.
type Store ¶
type Store interface {
// MarkDiscovered records that the scope has performed discovery.
MarkDiscovered(ctx context.Context, scopeKey string) error
// HasDiscovered reports whether the scope has performed discovery and the
// record has not expired.
HasDiscovered(ctx context.Context, scopeKey string) (bool, error)
// Cleanup evicts expired entries.
Cleanup(ctx context.Context) error
// Close releases any resources held by the store.
Close() error
}
Store records and reports discovery per scope key (an opaque string; see the package doc). Discovery is monotonic: once a scope has performed discovery, it stays discovered until its entry expires (bounded by the session timeout).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package postgres provides a PostgreSQL-backed searchgate.Store so the search-first gate's discovery signal is shared across replicas.
|
Package postgres provides a PostgreSQL-backed searchgate.Store so the search-first gate's discovery signal is shared across replicas. |