Repository navigation
Conversation
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.
问题
models/memory.py里 7 个from_dict(MemoryNode / SchemaNode / IntentionNode / KnowledgeGap / LifeStage / TemporalEvent / MemoryMetadata)各自定义的parse_dt/parse_datetime对 datetime 字段直接裸调datetime.fromisoformat(v)/datetime.fromtimestamp(v):payload 里只要有一个坏值(非法字符串、越界 epoch),整条反序列化就抛ValueError/OSError。影响面:
vector_store_base._payload_to_node裸调MemoryNode.from_dict(payload)。本 SDK 自己写 payload 时 datetime 转 int epoch 不会坏,但外部导入、迁移脚本、手工写入的 payload 可以带任意字符串——一条脏记忆会让整个 search / get 全挂,而不是丢那一条。最小复现
根因
hy_memory/models/memory.py:479(及 637/712/802/857/903/1199 同型):
改动
7 处
parse_dt/parse_datetime加 try/except,坏值降级None(随后由各 dataclass 的__post_init__兜底成当前时间),对齐仓库其他解析点已有的容错口径:coding/relational_repository._parse_dt:except Exception: return Nonepipelines/writer._collect_intentions:坏日期降级 None(tests/test_intention_recall.py 明确断言 "坏日期降级 None")pipelines/_retrieval/strength._epoch_seconds:坏值返回 None 并记日志有效输入(datetime 对象、int epoch、合法 ISO 串)的解析路径不变。
验证
新增 tests/test_from_dict_dirty_datetime.py:
回归(与改前基线逐条 diff 失败集合,Windows 既有环境失败非本次引入):
回滚
git revert本提交即可;改动只涉及 hy_memory/models/memory.py 的 7 个内嵌解析函数与一个新测试文件。