"""Hypothesis strategies for the redaction property tests (TS-13).

Co-located with the observability tests so the property tests share one
strategy set rather than defining it inline (the TS-13 `_strategies.py`
module requirement).
"""

from __future__ import annotations

from typing import Any

from hypothesis import strategies as st

# Default sensitive-key set per LG-04 / SC-09. Kept small here for
# strategy speed; the full set lives in the redaction module.
_SENSITIVE_KEYS = ("password", "token", "secret", "api_key", "authorization")
_SAFE_KEYS = ("name", "id", "count", "url", "host")


_scalar = st.one_of(
    st.text(max_size=40),
    st.integers(),
    st.floats(allow_nan=False, allow_infinity=False),
    st.booleans(),
    st.none(),
)


@st.composite
def _payload(draw: st.DrawFn) -> dict[str, Any]:
    """Generate a realistic log-record-like payload."""
    n_safe = draw(st.integers(min_value=0, max_value=3))
    n_sens = draw(st.integers(min_value=0, max_value=2))
    out: dict[str, Any] = {}
    for _ in range(n_safe):
        out[draw(st.sampled_from(_SAFE_KEYS))] = draw(_scalar)
    for _ in range(n_sens):
        out[draw(st.sampled_from(_SENSITIVE_KEYS))] = draw(_scalar)
    return out
