/**
 * Audit event types for tracking pipeline execution, gate decisions,
 * prompt delivery, and tool call traces.
 *
 * Every event carries a `verified` flag:
 *   false = self-reported (client LLM claims, e.g. begin_session intent)
 *   true  = server-verified (server-side data: tool responses, prompt matches, pipeline transforms)
 *
 * `correlationId` and `parentEventId` are designed for future causal graph
 * ingestion (e.g. graphiti knowledge graph).
 */

export type AuditEventKind =
  | 'pipeline_execution'       // Full pipeline run summary
  | 'stage_execution'          // Individual stage detail
  | 'gate_decision'            // Gate open/close with intent
  | 'prompt_delivery'          // Which prompts were sent to client
  | 'tool_call_trace'          // Tool call with server + timing
  | 'rbac_decision'            // RBAC allow/deny with subject + binding
  | 'session_bind';            // Client session bound to project

export type AuditSource = 'client' | 'mcplocal' | 'mcpd';

export interface AuditEvent {
  timestamp: string;
  sessionId: string;
  projectName: string;
  eventKind: AuditEventKind;
  source: AuditSource;
  verified: boolean;
  serverName?: string;
  correlationId?: string;
  parentEventId?: string;
  userName?: string;
  /** Set when the session authenticated via an McpToken (HTTP-mode mcplocal). */
  tokenName?: string;
  /** SHA-256 hash of the McpToken that made the request. */
  tokenSha?: string;
  payload: Record<string, unknown>;
}
