Problem
Some MineContext code paths mix legacy local naive datetime strings with newer ISO8601 timestamps that include a Z suffix or explicit UTC offset.
One concrete path is screenshot ingestion: the desktop frontend can submit create_time as an ISO string, while backend processing and monitoring code still compares values against naive local datetime.now() values. When aware and naive datetimes meet in comparison-heavy logic, Python can raise:
TypeError: can't compare offset-naive and offset-aware datetimes
Expected behavior
Datetime inputs from API payloads, storage rows, and generated context objects should be normalized before comparison so screenshot ingestion, vault scanning, processing, and scheduled consumption tasks can handle both legacy local strings and ISO8601 Z/offset strings.
Proposed fix
Normalize incoming datetime-like values to local naive datetime objects at the boundaries where they enter existing comparison logic, preserving compatibility with the current codebase's naive-local assumptions.
Related PR
Fix proposed in #367.
Verification from PR
python3 -m unittest tests/test_datetime_normalization.py
python3 -m py_compile opencontext/utils/datetime_utils.py opencontext/context_capture/vault_document_monitor.py opencontext/context_consumption/generation/smart_tip_generator.py opencontext/context_processing/processor/screenshot_processor.py opencontext/managers/consumption_manager.py opencontext/server/context_operations.py
Problem
Some MineContext code paths mix legacy local naive datetime strings with newer ISO8601 timestamps that include a
Zsuffix or explicit UTC offset.One concrete path is screenshot ingestion: the desktop frontend can submit
create_timeas an ISO string, while backend processing and monitoring code still compares values against naive localdatetime.now()values. When aware and naive datetimes meet in comparison-heavy logic, Python can raise:TypeError: can't compare offset-naive and offset-aware datetimesExpected behavior
Datetime inputs from API payloads, storage rows, and generated context objects should be normalized before comparison so screenshot ingestion, vault scanning, processing, and scheduled consumption tasks can handle both legacy local strings and ISO8601
Z/offset strings.Proposed fix
Normalize incoming datetime-like values to local naive
datetimeobjects at the boundaries where they enter existing comparison logic, preserving compatibility with the current codebase's naive-local assumptions.Related PR
Fix proposed in #367.
Verification from PR
python3 -m unittest tests/test_datetime_normalization.pypython3 -m py_compile opencontext/utils/datetime_utils.py opencontext/context_capture/vault_document_monitor.py opencontext/context_consumption/generation/smart_tip_generator.py opencontext/context_processing/processor/screenshot_processor.py opencontext/managers/consumption_manager.py opencontext/server/context_operations.py