@@ -156,6 +156,33 @@ func TestMemoryForgetReportsAbsenceRatherThanClaimingSuccess(t *testing.T) {
156156 }
157157}
158158
159+ func TestMemoryForgetPreservesANoteThatCannotBeRead (t * testing.T ) {
160+ paths := memoryTestPaths (t )
161+ if err := os .MkdirAll (paths .LocalDir , 0o700 ); err != nil {
162+ t .Fatal (err )
163+ }
164+ notePath := filepath .Join (paths .LocalDir , "unreadable.md" )
165+ // Oversize input is a deterministic, cross-platform read failure; unlike
166+ // permission bits, it behaves the same when tests run with elevated access.
167+ if err := os .WriteFile (notePath , []byte (strings .Repeat ("x" , 70 << 10 )), 0o600 ); err != nil {
168+ t .Fatal (err )
169+ }
170+ if _ , err := memory .Read (paths , memory .ScopeLocal , "unreadable" ); err == nil {
171+ t .Fatal ("oversized fixture unexpectedly remained readable" )
172+ }
173+
174+ result := NewMemoryForgetTool (paths ).Run (context .Background (), map [string ]any {"name" : "unreadable" })
175+ if result .Status != StatusError {
176+ t .Fatalf ("memory_forget deleted an unreadable note: %q" , result .Output )
177+ }
178+ if ! strings .Contains (strings .ToLower (result .Output ), "cannot read" ) {
179+ t .Fatalf ("memory_forget hid the read failure: %q" , result .Output )
180+ }
181+ if _ , err := os .Stat (notePath ); err != nil {
182+ t .Fatalf ("memory_forget removed the unreadable note: %v" , err )
183+ }
184+ }
185+
159186// One unreadable note must not empty the listing. memory.List deliberately
160187// returns what it could read alongside the failures; the tool returning an error
161188// instead threw that away, turning partial success back into total failure one
0 commit comments