Files
semantica/tests
6afe90e4fb fix(context): stamp AgentMemory in aware UTC, not mixed naive conventions (#1073)
* fix(context): stamp AgentMemory in aware UTC, not mixed naive conventions

MemoryItem timestamps had two producers with different naive conventions:
store() defaulted to datetime.now() (naive LOCAL) while from_dict fell back
to datetime.utcnow() (naive UTC). _timestamp_comparison_key interprets every
naive stamp as LOCAL time, so on any host off UTC the two producers disagree
by the host's offset — a UTC+8 host pushed freshly stored memories 8 hours
outside every start_date/end_date window, and cleanup_old_memories aged them
wrong by the same amount.

All three producers now stamp datetime.now(timezone.utc):

- store() default and the from_dict fallbacks stop introducing naive values;
- the cleanup cutoff compares against an aware instant instead of a naive
  local one;
- legacy naive stamps keep their documented local-time meaning through the
  comparison key, which is deliberately unchanged and now pinned by test.

Seven regression tests cover the producer contract, the naive-as-local
comparison semantics (so the key cannot silently flip to naive-as-UTC), the
isoformat round-trip, and end-to-end date-range filtering with UTC
boundaries on hosts in any timezone.

* test(context): rename add() references to store() in timestamp test

---------

Co-authored-by: Sameer Kadam <sskadam6305@gmail.com>
Co-authored-by: Sameer Kadam <sameerkadam@Mac.lan>
2026-09-10 15:16:35 +05:30
..
2026-06-16 04:43:45 +05:00