Repository navigation
Conversation
get_read_trace() sorted rows by ("event_at_ms or 0", created_at) while its own
comment promised to fall back to created_at when the event time is missing.
Rows written before the event_at_ms column existed carry 0, so every one of
them sorted ahead of all current rows no matter when it actually ran: a trace
that mixed legacy and current steps reported READ_REQUEST after the recall
steps it preceded.
Use the event time when present, otherwise the created_at instant, and put rows
with neither at the end so the rest of the order is untouched.
Two gaps in the first pass, both on rows that lack event_at_ms: - created_at can be written as "...Z" or with a space separator. Python 3.9/3.10's fromisoformat accepts neither and raises, so those rows all fell into the "unparsable" bucket and sorted last as a group instead of taking their place on the timeline. - the tie-breaker was the raw created_at value, so a missing one produced (inf, None) alongside (inf, ""), and sort() raised TypeError comparing None with str. Normalize both spellings before parsing and coerce the tie-breaker to str. The 3.9 behaviour is pinned by a test that swaps in a strict parser.
7 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更
MemoryInspector.async_get_read_trace()的注释写的是「按 event_at_ms 升序;缺省回落 created_at 保持稳定」,但代码是:event_at_ms对补列之前写入的历史行是0(cache_sqlite._migrate_pipeline_logs_columns给旧库 ALTER 出来的列默认 0),于是这些行的排序键变成(0, created_at),恒定排在所有带真实时刻的行前面,跟注释承诺的回退语义正好相反。改成一个小的取键函数:有
event_at_ms用它,没有就解析created_at成同一量纲,两者都拿不到时排到最后(list.sort稳定,其余行顺序不变)。用户影响
get_full_trace/get_read_trace的steps、by_step顺序,以及 UI 按这个顺序渲染的 read pipeline 时间线。一次 search 的 trace 里如果混有历史行(升级前写的库),READ_REQUEST会显示在它之后发生的 recall 步骤后面,读起来像"请求发生在召回之后"。只影响 trace 的展示顺序,不改变任何检索结果或落库内容。
验证
tests/test_read_trace_step_order.py(3 例)test_op_trace_logs.py+test_pipeline_observability.py+test_pipeline_log_user_lookup.py→ 32 passedhy_memory/inspector.py,上面两例立刻变红;恢复后 3 passed隐私与安全
datetime)回滚
一个排序键 + 一个测试文件,可整体 revert。