File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -381,8 +381,9 @@ export class MemoryUpgrader {
381381 } ;
382382
383383 // Step 4: Update the memory entry (store.update() handles its own lock)
384+ // [FIX] 不再覆蓋 text,保留 original 內容,避免部分寫入後 crash 無法恢復
385+ // metadata 內含 l0_abstract,recall 時會使用
384386 await this . store . update ( entry . id , {
385- text : enriched . l0_abstract ,
386387 metadata : stringifySmartMetadata ( newMetadata ) ,
387388 } ) ;
388389 success ++ ;
Original file line number Diff line number Diff line change @@ -369,11 +369,13 @@ async function testNoOverwriteBetweenPluginAndUpgrader() {
369369 // 檢查最終狀態
370370 const final = store . state . data . get ( "entry-1" ) ;
371371 console . log ( ` 最終 text: ${ final . text . substring ( 0 , 30 ) } ...` ) ;
372+ console . log ( ` 最終 metadata: ${ final . metadata ?. substring ( 0 , 30 ) } ...` ) ;
372373 console . log ( ` 最終 injected_count: ${ final . injected_count } ` ) ;
373374 console . log ( ` 總更新次數: ${ allUpdates . length } ` ) ;
374375
375- // 驗證:text 被更新(upgrader),injected_count 也被保留(plugin)
376- assert . ok ( final . text !== "Original text" , "Upgrader 應該更新 text" ) ;
376+ // 驗證:text 保留原樣,metadata 被更新(包含 l0_abstract),injected_count 保留(plugin)
377+ assert . equal ( final . text , "Original text that needs upgrading" , "Upgrader 不應覆蓋 text,保留 original" ) ;
378+ assert . ok ( final . metadata . includes ( "l0_abstract" ) , "Upgrader 應該更新 metadata" ) ;
377379 assert . equal ( final . injected_count , 5 , "Plugin 寫入的 injected_count 應該保留" ) ;
378380
379381 // 顯示更新的欄位
@@ -382,7 +384,7 @@ async function testNoOverwriteBetweenPluginAndUpgrader() {
382384 console . log ( ` Text 更新次數: ${ textUpdates . length } ` ) ;
383385 console . log ( ` injected_count 更新次數: ${ countUpdates . length } ` ) ;
384386
385- console . log ( " ✅ Test 5 通過:Plugin 和 Upgrader 更新不同欄位,互不覆蓋" ) ;
387+ console . log ( " ✅ Test 5 通過:Plugin 和 Upgrader 更新不同欄位,互不覆蓋(text 保留,metadata 更新) " ) ;
386388}
387389
388390// ============================================================================
You can’t perform that action at this time.
0 commit comments