fix(sensor): bound WarpParser to a recent-conversation window
What type of PR is this? (check all applicable)
- [ ] Refactor
- [ ] Feature
- [x] Bug Fix
- [x] Optimization
- [ ] Documentation Update
Related issue: Closes #17
What changed?
WarpParser now takes a max_age_days parameter (default 14, matching MAX_CONVERSATION_AGE_DAYS used elsewhere) and filters conversations by last_modified_at before running the per-conversation exchange query, mirroring the existing pattern in CursorParser. The conversation-listing query also drops the unused conversation_data column. AgentObserver now threads max_age_days through to WarpParser the same way it already does for ClaudeParser/CursorParser/ClaudeDesktopParser, so --all-history applies consistently across all SQLite/JSONL-backed sources instead of silently skipping Warp.
Why?
Warp conversation history in warp.sqlite grows unboundedly with normal usage, and the sensor is expected to run repeatedly (cron/launchd) on end-user machines. Without an age cutoff, every run re-scanned the full agent_conversations table and issued a separate SQL JOIN per conversation ever recorded — cost that only grows over time. ClaudeParser, CursorParser, and ClaudeDesktopParser already solve this with an identical max_age_days cutoff pattern; WarpParser was the one SQLite-backed parser missing it.
How did you test it?
Added TestWarpParser to tests/test_parsers.py (previously no coverage existed for this parser) against a synthetic SQLite DB matching the real schema (agent_conversations, ai_queries, ai_blocks): verifies old conversations are excluded, a larger max_age_days override includes them again, conversation content (user query + assistant tool-use message) still parses correctly, and empty-DB/default-constant behavior.
Ran the full existing suite locally with pytest tests/ -v:
64 passed, 1 warning (pre-existing, unrelated to this change) — click to expand
============================= test session starts ==============================
platform darwin -- Python 3.14.0, pytest-9.1.1, pluggy-1.6.0 -- /private/tmp/adr_sensor_venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/test4/Desktop/OSS/Uber ADR/Sensor
configfile: pyproject.toml
collecting ... collected 64 items
tests/test_cli.py::test_cli_version_matches_package_metadata PASSED [ 1%]
tests/test_observer.py::TestAgentObserver::test_init_default PASSED [ 3%]
tests/test_observer.py::TestAgentObserver::test_display_summary_empty PASSED [ 4%]
tests/test_observer.py::TestAgentObserver::test_display_summary_with_entries PASSED [ 6%]
tests/test_observer.py::TestAgentObserver::test_save_to_file_json PASSED [ 7%]
tests/test_observer.py::TestAgentObserver::test_save_to_file_jsonl PASSED [ 9%]
tests/test_observer.py::TestAgentObserver::test_save_sessions_individual PASSED [ 10%]
tests/test_observer.py::TestAgentObserver::test_clean_filename PASSED [ 12%]
tests/test_observer.py::TestAgentObserver::test_filter_entries_by_existing_files PASSED [ 14%]
tests/test_observer.py::TestAgentObserver::test_ingest_all_handles_parser_errors PASSED [ 15%]
tests/test_parsers.py::TestClaudeParser::test_parse_jsonl_file PASSED [ 17%]
tests/test_parsers.py::TestClaudeParser::test_parse_empty_file PASSED [ 18%]
tests/test_parsers.py::TestClaudeParser::test_parse_all_no_directory PASSED [ 20%]
tests/test_parsers.py::TestClaudeParser::test_truncate_large_arguments PASSED [ 21%]
tests/test_parsers.py::TestClineParser::test_parse_cline_log PASSED [ 23%]
tests/test_parsers.py::TestClineParser::test_extract_mcp_tools PASSED [ 25%]
tests/test_parsers.py::TestClineParser::test_parse_no_directory PASSED [ 26%]
tests/test_parsers.py::TestCodexParser::test_parse_jsonl_file PASSED [ 28%]
tests/test_parsers.py::TestCodexParser::test_parse_no_directory PASSED [ 29%]
tests/test_parsers.py::TestWarpParser::test_skips_conversations_older_than_max_age PASSED [ 31%]
tests/test_parsers.py::TestWarpParser::test_all_history_via_large_max_age_days PASSED [ 32%]
tests/test_parsers.py::TestWarpParser::test_parses_conversation_content PASSED [ 34%]
tests/test_parsers.py::TestWarpParser::test_parse_all_no_database PASSED [ 35%]
tests/test_parsers.py::TestWarpParser::test_default_max_age_days PASSED [ 37%]
tests/test_schemas.py::TestToolUsage::test_create_basic PASSED [ 39%]
tests/test_schemas.py::TestToolUsage::test_create_with_all_fields PASSED [ 40%]
tests/test_schemas.py::TestToolUsage::test_frozen PASSED [ 42%]
tests/test_schemas.py::TestChatMessage::test_create_user_message PASSED [ 43%]
tests/test_schemas.py::TestChatMessage::test_create_assistant_message_with_tools PASSED [ 45%]
tests/test_schemas.py::TestAgentEvent::test_create_basic PASSED [ 46%]
tests/test_schemas.py::TestAgentEvent::test_uuid_deterministic PASSED [ 48%]
tests/test_schemas.py::TestAgentEvent::test_uuid_unique_for_different_sessions PASSED [ 50%]
tests/test_schemas.py::TestAgentEvent::test_has_meaningful_content_empty PASSED [ 51%]
tests/test_schemas.py::TestAgentEvent::test_has_meaningful_content_single_error PASSED [ 53%]
tests/test_schemas.py::TestAgentEvent::test_has_meaningful_content_real_conversation PASSED [ 54%]
tests/test_schemas.py::TestAgentEvent::test_has_meaningful_content_with_tools PASSED [ 56%]
tests/test_schemas.py::TestAgentEvent::test_has_tool_usage PASSED [ 57%]
tests/test_schemas.py::TestAgentEvent::test_to_dict PASSED [ 59%]
tests/test_schemas.py::TestAgentEvent::test_to_json PASSED [ 60%]
tests/test_schemas.py::TestAgentEvent::test_get_summary PASSED [ 62%]
tests/test_schemas.py::TestAgentEvent::test_get_content_hash PASSED [ 64%]
tests/test_schemas.py::TestAgentEvent::test_get_non_null_fields PASSED [ 65%]
tests/test_schemas.py::TestAgentEvent::test_auto_populates_hostname_username PASSED [ 67%]
tests/test_utils.py::TestTruncateMiddle::test_short_string_unchanged PASSED [ 68%]
tests/test_utils.py::TestTruncateMiddle::test_empty_string PASSED [ 70%]
tests/test_utils.py::TestTruncateMiddle::test_none_string PASSED [ 71%]
tests/test_utils.py::TestTruncateMiddle::test_exact_length_unchanged PASSED [ 73%]
tests/test_utils.py::TestTruncateMiddle::test_truncation PASSED [ 75%]
tests/test_utils.py::TestTruncateMiddle::test_custom_edge_chars PASSED [ 76%]
tests/test_utils.py::TestNormalizeTimestamp::test_iso_string PASSED [ 78%]
tests/test_utils.py::TestNormalizeTimestamp::test_iso_string_with_offset PASSED [ 79%]
tests/test_utils.py::TestNormalizeTimestamp::test_unix_timestamp_seconds PASSED [ 81%]
tests/test_utils.py::TestNormalizeTimestamp::test_unix_timestamp_milliseconds PASSED [ 82%]
tests/test_utils.py::TestNormalizeTimestamp::test_datetime_naive PASSED [ 84%]
tests/test_utils.py::TestNormalizeTimestamp::test_datetime_aware PASSED [ 85%]
tests/test_utils.py::TestNormalizeTimestamp::test_string_unix_timestamp PASSED [ 87%]
tests/test_utils.py::TestNormalizeTimestamp::test_invalid_string PASSED [ 89%]
tests/test_utils.py::TestNormalizeTimestamp::test_invalid_type PASSED [ 90%]
tests/test_utils.py::TestNormalizeTimestamp::test_float_timestamp PASSED [ 92%]
tests/test_utils.py::TestFormatTimestampForFilename::test_format PASSED [ 93%]
tests/test_utils.py::TestParseTimestampFromFilename::test_valid_filename PASSED [ 95%]
tests/test_utils.py::TestParseTimestampFromFilename::test_invalid_filename PASSED [ 96%]
tests/test_utils.py::TestParseTimestampFromFilename::test_none_filename PASSED [ 98%]
tests/test_utils.py::TestParseTimestampFromFilename::test_malformed_timestamp PASSED [100%]
=============================== warnings summary ===============================
tests/test_observer.py::TestAgentObserver::test_ingest_all_handles_parser_errors
/Users/test4/Desktop/OSS/Uber ADR/Sensor/adr_sensor/observer.py:66: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
"timestamp": datetime.utcnow().isoformat(timespec="milliseconds") + "Z",
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================== 64 passed, 1 warning in 0.10s =========================
Potential risks
Low. The filtering logic is a direct mirror of CursorParser's already-shipped behavior. The only behavior change for existing users: conversations older than 14 days are no longer re-ingested by default — same tradeoff already accepted for Claude/Cursor/Claude Desktop, and overridable via max_age_days/--all-history.