From ba07dcb6c71d1398a5af3102efa715faf627bbe7 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 May 2026 17:50:28 +0000 Subject: [PATCH] feat(audit): re-enable audit log (kill switch off by default) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 1 diagnostic build validated end-to-end on the user's machine: session cf2ebbd5 (2026-05-19) produced session/upload/analyze/nav/ session-end events with no blank-pages regression. Root cause of the original symptom was the audit_log_path/_session_id deadlock fixed in a8ff8f4 — the kill switch is no longer load-bearing. Flips ``_DISABLED: True`` → ``False`` so the default install writes a log. The three env-var overrides (``DATATOOLS_AUDIT_ENABLED``, ``DATATOOLS_AUDIT_TRACE``, ``DATATOOLS_AUDIT_PROBE``) and the writer- thread BaseException guard from 76c9f5a stay in place as escape hatches if the symptom ever recurs. TestKillSwitchContract continues to pass — it monkeypatches ``_DISABLED = True`` explicitly and doesn't rely on the module default. Rollback: ``git revert HEAD`` flips the switch back without removing the diagnostic instrumentation. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/audit.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/audit.py b/src/audit.py index 6880973..882d969 100644 --- a/src/audit.py +++ b/src/audit.py @@ -55,17 +55,19 @@ _LOG_PATH: Path | None = None _SESSION_ID: str | None = None _SESSION_STARTED: bool = False -# RESTORED kill switch — the async-writer redesign still triggers the -# blank-pages symptom on the user's machine despite no synchronous -# file I/O on the request path. Cause is not yet identified; keep all -# log_* calls as no-ops by default while we diagnose. +# Kill switch — held off by default now that the blank-pages symptom +# is traced to the audit_log_path/_session_id deadlock fixed in +# a8ff8f4. End-to-end validation in session cf2ebbd5 (2026-05-19) +# wrote session/upload/analyze/nav/session-end events with no +# regression. Flip back to ``True`` if the symptom recurs; the env +# vars below stay as escape hatches. # -# Diagnostic overrides for an instrumented run (DO NOT set in prod): -# DATATOOLS_AUDIT_ENABLED=1 — bypass _DISABLED for one session +# Env-var overrides (still wired): +# DATATOOLS_AUDIT_ENABLED=1 — force-on even if _DISABLED is True # DATATOOLS_AUDIT_TRACE=1 — print "[audit] ..." lines to stderr # DATATOOLS_AUDIT_PROBE=... — bisect the producer path. Values: # full (default) | noop | no-events | no-page-open | no-session-start -_DISABLED: bool = True +_DISABLED: bool = False _ENABLE_OVERRIDE: bool = os.environ.get("DATATOOLS_AUDIT_ENABLED") == "1" _TRACE: bool = os.environ.get("DATATOOLS_AUDIT_TRACE") == "1" _PROBE: str = os.environ.get("DATATOOLS_AUDIT_PROBE", "full").lower()