修复 harness 中 memory glob 路径归一化问题#1481
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
@LearningGp 麻烦审核一下下谢谢 |
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR fixes a real path normalization bug in MemoryConsolidator.readDailyEntries where LocalFilesystem.glob() returns absolute paths that the old toRelative() helper couldn't handle, causing daily memory files to be silently skipped. The fix introduces a centralized WorkspaceManager.toWorkspaceRelativePath() method that correctly handles absolute paths (via Path.startsWith + relativize), virtual/remote paths (leading / stripping), and Windows separators. The refactoring is clean — the eligible list now stores already-normalized relative strings instead of FileInfo objects, eliminating the redundant toRelative() call. Test coverage is solid, including a targeted regression test (consolidate_localFilesystem_readsRootDailyFile) that reproduces the exact bug scenario with LocalFilesystem.
概述
修复
MemoryConsolidator在处理memory/*.md时对路径归一化不一致的问题,避免本地文件系统返回绝对路径或 Windows 路径时,根目录下的日记文件被漏读、漏合并。变更内容
WorkspaceManager.toWorkspaceRelativePath(...),统一把文件系统返回的路径转换为 workspace 相对路径。MemoryConsolidator在读取 daily ledger 时,先将glob结果归一化,再进行过滤、排序和读取。fileName(...),兼容 Windows 路径分隔符。LocalFilesystem下根目录memory/2026-05-20.md的合并场景。验证
mvn -s codex-maven-settings.xml -pl agentscope-harness -am "-Dtest=MemoryConsolidatorFilesystemTest,FilesystemGlobTest" test