refactor: nuke `events.jsonl` pipeline and the unused PII sanitizer

The JSONL trace sink was never read — TUI consumes ``Tracer`` state
directly (chat_messages, agents, tool_executions, vulnerability_reports,
LLM stats), and SQLiteSession owns the conversation history. The whole
``StrixTracingProcessor`` → ``_emit_event`` → ``append_jsonl_record``
pipeline was producing files nothing opens.

Deleted:
- ``strix/telemetry/strix_processor.py`` (the SDK ``TracingProcessor``).
- ``strix/telemetry/utils.py`` — ``TelemetrySanitizer`` (no remaining
  callers), ``append_jsonl_record``, ``get_events_write_lock``,
  ``reset_events_write_locks``.
- ``strix/telemetry/flags.py`` — ``is_telemetry_enabled`` /
  ``is_posthog_enabled`` collapsed into a 4-line check inside
  ``posthog._is_enabled`` (its only caller).
- ``Tracer._emit_event`` and every event-emit call inside the tracer
  (``run.started``, ``run.configured``, ``run.completed``,
  ``finding.created``, ``finding.reviewed``, ``chat.message``).
- ``Tracer._enrich_actor`` (only used by ``_emit_event``).
- ``Tracer._sanitize_data`` + ``_sanitizer`` field (PII scrub only ran
  on JSONL events).
- ``Tracer.events_file_path`` property and the ``_events_file_path`` /
  ``_telemetry_enabled`` / ``_run_completed_emitted`` /
  ``_next_execution_id`` fields.
- ``Tracer._calculate_duration`` (one caller in posthog — inlined).
- ``add_trace_processor(StrixTracingProcessor(run_dir))`` from
  ``entry.py``.

The ``Tracer`` class is now ~275 LoC of pure runtime state for the TUI
+ vulnerability artifact writer (markdown / CSV / pentest report).
Conversation history goes to ``SQLiteSession``; SDK trace events are
not persisted.
This commit is contained in:
0xallam
2026-04-25 13:47:37 -07:00
parent d3449556b7
commit 7296d8aabd
6 changed files with 39 additions and 463 deletions
+20 -3
View File
@@ -6,7 +6,7 @@ from pathlib import Path
from typing import TYPE_CHECKING, Any
from uuid import uuid4
from strix.telemetry.flags import is_posthog_enabled
from strix.config import Config
if TYPE_CHECKING:
@@ -15,11 +15,18 @@ if TYPE_CHECKING:
_POSTHOG_PUBLIC_API_KEY = "phc_7rO3XRuNT5sgSKAl6HDIrWdSGh1COzxw0vxVIAR6vVZ"
_POSTHOG_HOST = "https://us.i.posthog.com"
_DISABLED_VALUES = {"0", "false", "no", "off"}
_SESSION_ID = uuid4().hex[:16]
def _is_enabled() -> bool:
return is_posthog_enabled()
"""Master telemetry gate. ``STRIX_POSTHOG_TELEMETRY`` overrides ``STRIX_TELEMETRY``."""
explicit = Config.get("strix_posthog_telemetry")
if explicit is not None:
return explicit.strip().lower() not in _DISABLED_VALUES
fallback = Config.get("strix_telemetry") or "1"
return fallback.strip().lower() not in _DISABLED_VALUES
def _is_first_run() -> bool:
@@ -114,12 +121,22 @@ def end(tracer: "Tracer", exit_reason: str = "completed") -> None:
llm = tracer.get_total_llm_stats()
total = llm.get("total", {})
duration = 0.0
try:
from datetime import datetime
start = datetime.fromisoformat(tracer.start_time.replace("Z", "+00:00"))
end_iso = tracer.end_time or datetime.now(start.tzinfo).isoformat()
duration = (datetime.fromisoformat(end_iso.replace("Z", "+00:00")) - start).total_seconds()
except (ValueError, TypeError, AttributeError):
pass
_send(
"scan_ended",
{
**_base_props(),
"exit_reason": exit_reason,
"duration_seconds": round(tracer._calculate_duration()),
"duration_seconds": round(duration),
"vulnerabilities_total": len(tracer.vulnerability_reports),
**{f"vulnerabilities_{k}": v for k, v in vulnerabilities_counts.items()},
"agent_count": len(tracer.agents),