Files
semantica/tests/provenance
FABIOTESSandClaude Opus 5 e03212cd66 fix(provenance): compare timestamp ranges by instant, not by spelling
Review finding on #1121, and correct: with new entries carrying +00:00
and entries written earlier carrying nothing, query_recorded_between()
and audit_log() compared ISO strings directly, which orders by how a
timestamp is spelled rather than when it happened.

Two consequences, both introduced by the offset this PR adds:

- An inclusive naive bound naming a stored offset-bearing timestamp
  sorts below it, because the stored value is the longer string, so the
  record it names is excluded from its own range.
- A bound in another offset lands wherever its digits fall.
  "2026-08-19T19:45:00+05:30" is 14:15Z, before an entry at 14:19Z, but
  string comparison puts it after.

Both paths now compare instants, through a new to_utc_datetime() helper
that reads a missing offset as UTC. That is what the naive values
actually were: provenance stamped with datetime.utcnow(), so reading
them as UTC keeps a stored naive value and the same instant written with
an offset comparing equal instead of ordering by representation. It is
also the read side the remaining 147 call sites will need whenever the
rest of the package is converted.

A bound that cannot be read as a timestamp keeps the historical string
comparison rather than raising on a call that used to work.

Five new tests cover the inclusive naive bound, the other-offset bound,
legacy and offset-bearing entries ordered together, audit_log's since
filter, and the unreadable-bound fallback. The first two fail with
manager.py reverted; the rest are guards.

569 provenance, export and ontology tests pass, and the full-suite
failure set is unchanged at 329, all from optional dependencies missing
locally.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-19 15:58:24 +01:00
..
2026-07-31 16:05:37 +05:30