feat(audit): re-enable audit log (kill switch off by default)
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 ina8ff8f4— 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 from76c9f5astay 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) <noreply@anthropic.com>
This commit is contained in:
16
src/audit.py
16
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()
|
||||
|
||||
Reference in New Issue
Block a user