Repository navigation
feat(memory): restore unauthorized MEMORY.md dated entry deletions at turn end - #45
Merged
Merged
Conversation
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.
요약
memory_update를 거치지 않고 파일 도구·셸로MEMORY.md의 기존 dated entry를 직접 덮어쓰거나 삭제한 경우, 턴 종료(endMemoryTurn) 시 기존memory-journal.ts스냅샷을 재사용해 사라진 엔트리만 최신 디스크 내용에 안전하게 병합 복원합니다(via: "deletion-guard").POST /api/internal/memory경로를journalBotMemoryUpdate()로 감싸 정상memory_update(append·replace·remove·supersede·forget)가 저널(via: "memory_update")과 baseline을 즉시 갱신하도록 연결했습니다. 따라서 합법적 삭제(remove·forget)는 되살아나지 않습니다.변경 이유
MEMORY.md를 덮어쓰거나rm으로 지워도 저널에만 기록될 뿐 기존 기억이 그대로 유실되었습니다.parseMemoryEntries+factIdentity로 누락된 dated entry만 추출해expectedHashCAS(writeMemoryDoc)로 병합 복원하므로, 동시 스레드·사용자 UI·upkeep이 추가한 새 줄이 유실되지 않습니다.변경 파일
server/memory-journal.ts:findMissingMemoryEntries,restoreMissingMemoryEntries,journalBotMemoryUpdate추가,advanceBaseline에서 캐시 stat 무효화,reconcile의via: "turn"경로에MEMORY.md복원 연결server/index.ts:POST /api/internal/memory에서botMemoryUpdate를journalBotMemoryUpdate로 감쌈Before / After 증적
MEMORY.md를 직접 덮어쓰거나 삭제(rm MEMORY.md)하면endMemoryTurn이via: "turn"diff만 기록하고 삭제된 dated entry는 복구되지 않음.node -e7개 실시나리오 검증 결과):1_direct_drop_merge: Fact B 직접 삭제 + Fact C 추가 →vias: ["turn", "deletion-guard"], Fact A·B·C 모두 보존2_rm_memory_md:MEMORY.md파일 삭제 →vias: ["turn", "deletion-guard"], Critical Fact 복원3_authorized_remove:memory_update(remove)→endRows: 0, 삭제 유지(부활 없음)4_authorized_forget:memory_update(forget)→endRows: 0, 삭제 유지(부활 없음)5_drop_then_append: 직접 삭제 후 같은 턴memory_update(append)→ 먼저 복원 후 append, A·B·C 모두 보존6_person_disk_delete: 턴 사이 사용자 직접 편집 삭제 → 삭제 유지7_person_ui_delete: 턴 중 사용자 UI 삭제 →endRows: 0, 삭제 유지검증
npx vitest run server/memory-journal.test.ts server/memory-entries.test.ts server/memory-forget.test.ts server/memory-upkeep.test.ts: 4 files, 108 passedpnpm typecheck: 통과pnpm lint: 통과vocabulary.test.ts,file-size-ratchet.test.ts): 통과