| 13 | |
| 14 | |
| 15 | def _log_path() -> Path | None: |
| 16 | # Opt-in only (#1797). The log records every query/path/explain question and |
| 17 | # corpus path (and full responses if GRAPHIFY_QUERY_LOG_RESPONSES) in a |
| 18 | # plaintext file under ~/.cache — outside any repo's .gitignore/retention. A |
| 19 | # default-on record of proprietary queries contradicts graphify's on-device, |
| 20 | # no-telemetry posture, so it is OFF unless explicitly enabled: |
| 21 | # GRAPHIFY_QUERY_LOG=<path> log to that path, or |
| 22 | # GRAPHIFY_QUERY_LOG_ENABLE=1 log to ~/.cache/graphify-queries.log. |
| 23 | # GRAPHIFY_QUERY_LOG_DISABLE=1 still forces it off (back-compat, wins). |
| 24 | if os.environ.get("GRAPHIFY_QUERY_LOG_DISABLE", "").lower() in ("1", "true", "yes"): |
| 25 | return None |
| 26 | override = os.environ.get("GRAPHIFY_QUERY_LOG", "").strip() |
| 27 | if override: |
| 28 | return Path(override).expanduser() |
| 29 | if os.environ.get("GRAPHIFY_QUERY_LOG_ENABLE", "").lower() in ("1", "true", "yes"): |
| 30 | return Path.home() / ".cache" / "graphify-queries.log" |
| 31 | return None |
| 32 | |
| 33 | |
| 34 | def _log_responses() -> bool: |