(event security.Event, payload map[string]any)
| 231 | } |
| 232 | |
| 233 | func (s Service) recordEvent(event security.Event, payload map[string]any) (security.DecisionRecord, error) { |
| 234 | payload["recorded_at"] = time.Now().UTC().Format(time.RFC3339Nano) |
| 235 | keys := make([]string, 0, len(payload)) |
| 236 | for key := range payload { |
| 237 | keys = append(keys, key) |
| 238 | } |
| 239 | sort.Strings(keys) |
| 240 | ordered := make(map[string]any, len(payload)) |
| 241 | for _, key := range keys { |
| 242 | ordered[key] = payload[key] |
| 243 | } |
| 244 | raw, err := json.Marshal(ordered) |
| 245 | if err != nil { |
| 246 | return security.DecisionRecord{}, err |
| 247 | } |
| 248 | return security.EvaluateAndPersist(s.DB, event, string(raw)) |
| 249 | } |
| 250 | |
| 251 | func ensureToolCallID(toolCallID string) string { |
| 252 | if strings.TrimSpace(toolCallID) != "" { |
no test coverage detected