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

Function scanProtectionEventsForUser

internal/identity/user_data_rights.go:213–235  ·  view source on GitHub ↗

scanProtectionEventsForUser loads the screening audit log across all the user's agents (metadata projection — see ProtectionEventExportEntry).

(ctx context.Context, tx pgx.Tx, userID string)

Source from the content-addressed store, hash-verified

211// scanProtectionEventsForUser loads the screening audit log across all the user's
212// agents (metadata projection — see ProtectionEventExportEntry).
213func scanProtectionEventsForUser(ctx context.Context, tx pgx.Tx, userID string) ([]ProtectionEventExportEntry, error) {
214 rows, err := tx.Query(ctx,
215 `SELECT pe.id, pe.message_id, pe.agent_id, pe.direction, pe.source, pe.reason,
216 pe.action, COALESCE(pe.subject_addr, ''), COALESCE(pe.detector, ''), pe.score, pe.created_at
217 FROM protection_events pe
218 JOIN agent_identities a ON a.id = pe.agent_id
219 WHERE a.user_id = $1
220 ORDER BY pe.created_at DESC`, userID)
221 if err != nil {
222 return nil, err
223 }
224 defer rows.Close()
225 out := []ProtectionEventExportEntry{}
226 for rows.Next() {
227 var e ProtectionEventExportEntry
228 if err := rows.Scan(&e.ID, &e.MessageID, &e.AgentID, &e.Direction, &e.Source, &e.Reason,
229 &e.Action, &e.SubjectAddr, &e.Detector, &e.Score, &e.CreatedAt); err != nil {
230 return nil, err
231 }
232 out = append(out, e)
233 }
234 return out, rows.Err()
235}
236
237// DeleteUserDataResult breaks out per-table row counts for audit logs.
238// Operators receiving a deletion request often have to attest to what

Callers 1

ExportUserDataMethod · 0.85

Calls 5

QueryMethod · 0.80
NextMethod · 0.80
ScanMethod · 0.80
ErrMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected