// Telemetry constants for spans, attributes, metrics, and logs used by the policy engine.
// Keeping these centralized avoids magic strings and keeps naming consistent across the crate.

// Span names (some call sites use literals directly due to macro constraints)
#[allow(dead_code)]
pub const SPAN_NAME_EVALUATING_ACTION: &str = "evaluating_action";
#[allow(dead_code)]
pub const SPAN_NAME_EVALUATING_POLICY: &str = "evaluating_policy";

// Common span attribute keys
pub const ATTR_TOOL_NAME: &str = "tool_name";
pub const ATTR_TOOL_CALL_ID: &str = "tool_call_id";
pub const ATTR_TOOL_ARGS: &str = "tool_args";
pub const ATTR_TOOL_ARGS_REDACTED_FIELDS: &str = "tool_args_redacted_fields";
pub const ATTR_AGENT_STATE: &str = "agent_state";
pub const ATTR_AGENT_STATE_REDACTED_FIELDS: &str = "agent_state_redacted_fields";

pub const ATTR_POLICY_ID: &str = "policy_id";
pub const ATTR_POLICY_VERSION_ID: &str = "policy_version_id";

pub const ATTR_POLICY_STATUS: &str = "policy_status";

pub const ATTR_EFFECT: &str = "effect";
pub const ATTR_EFFECT_REASON: &str = "effect_reason";
pub const ATTR_MATCHED: &str = "matched";
pub const ATTR_CONDITION_EVALUATION_ERRORS: &str = "condition_evaluation_errors";

pub const ATTR_DECISION: &str = "decision";
pub const ATTR_DECISION_REASON: &str = "decision_reason";
pub const ATTR_MATCHED_COUNT: &str = "matched_count";
pub const ATTR_POLICIES_SKIPPED: &str = "policies_skipped";
pub const POLICIES_SKIPPED_SERIALIZATION_ERROR: &str = "[{\"error\":\"Some policies were skipped, but an error was encountered while trying to serialize them.\"}]";

// Common attribute values
pub const EFFECT_ALLOW: &str = "allow";
pub const EFFECT_DENY: &str = "deny";
pub const EFFECT_MODIFY: &str = "modify";
pub const EFFECT_NONE: &str = "none";
pub const EFFECT_UNKNOWN: &str = "unknown";

// Effect reason strings
pub const EFFECT_REASON_ALLOW_MATCHED: &str = "Explicitly matched allow condition";
pub const EFFECT_REASON_ALLOW_MISMATCHED: &str = "Explicitly mismatched allow condition";
pub const EFFECT_REASON_DENY_MATCHED: &str = "Explicitly matched deny condition";
pub const EFFECT_REASON_DENY_MISMATCHED: &str = "Explicitly mismatched deny condition";

pub const EVAL_FAIL_ALLOW_PREFIX: &str =
    "Failed to evaluate allow condition for the following reason:";
pub const EVAL_FAIL_DENY_PREFIX: &str =
    "Failed to evaluate deny condition for the following reason:";
pub const EVAL_FAIL_MODIFY_PREFIX: &str =
    "Failed to evaluate modify condition for the following reason:";

// Metrics
pub const METER_NAME: &str = "policy-engine";
pub const HISTOGRAM_DECISION_LATENCY_MS: &str = "policy_engine.decision_latency_ms";
pub const HISTOGRAM_DECISION_LATENCY_DESC: &str = "Latency of policy decisions in milliseconds";
pub const UNIT_MS: &str = "ms";
pub const METRIC_ATTR_TOOL_NAME: &str = "tool_name";
pub const METRIC_ATTR_DECISION: &str = "decision";

// Logs
pub const LOGGER_NAME: &str = "policy_engine";
pub const LOG_EVENT_PROCESS_TOOL_CALL_RESULT: &str = "process_tool_call_result";
pub const LOG_TARGET_DECISION: &str = "policy_engine::decision";
pub const LOG_SEVERITY_INFO: &str = "INFO";

// Errors
pub const ATTR_TELEMETRY_ERRORS: &str = "telemetry_errors";
pub const TELEMETRY_SERIALIZATION_ERROR: &str = "[\"Errors occurred while serializing telemetry, but an error was encountered while trying to serialize them.\"]";
