MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / ListProtectionEventsByAgent

Method ListProtectionEventsByAgent

internal/identity/screening.go:106–124  ·  view source on GitHub ↗

ListProtectionEventsByAgent returns an agent's most recent screening events (newest first, capped by limit) for the security/analytics view.

(ctx context.Context, agentID string, limit int)

Source from the content-addressed store, hash-verified

104// ListProtectionEventsByAgent returns an agent's most recent screening events
105// (newest first, capped by limit) for the security/analytics view.
106func (s *Store) ListProtectionEventsByAgent(ctx context.Context, agentID string, limit int) ([]ProtectionEvent, error) {
107 if limit <= 0 || limit > 1000 {
108 limit = 100
109 }
110 rows, err := s.pool.Query(ctx,
111 `SELECT id, message_id, agent_id, direction, source, reason, action,
112 subject_addr, detector, score, categories, spans, raw, created_at
113 FROM protection_events
114 WHERE agent_id = $1
115 ORDER BY created_at DESC, id
116 LIMIT $2`,
117 agentID, limit,
118 )
119 if err != nil {
120 return nil, fmt.Errorf("list screening events by agent: %w", err)
121 }
122 defer rows.Close()
123 return scanProtectionEvents(rows)
124}
125
126// rowScanner is the minimal surface of pgx.Rows used here, so scanProtectionEvents
127// stays decoupled from the concrete driver type.

Implementers 1

Storeinternal/identity/store.go

Calls 3

scanProtectionEventsFunction · 0.85
QueryMethod · 0.80
CloseMethod · 0.45

Tested by 1