Enable bounded proximity conversations and confirmed social memories
This commit is contained in:
@@ -39,3 +39,37 @@ test('conversation failure, queued delivery, confirmed memory and replay safety'
|
||||
assert.equal(failed,'Bot offline');assert.equal(bot.memories.length,1);
|
||||
}finally{global.fetch=originalFetch;}
|
||||
});
|
||||
|
||||
test('social exchanges remember both residents only after confirmed reply and replays are harmless',async()=>{
|
||||
const a={id:'a',name:'A',status:'online',autonomy:{managed:true},memories:[],relationships:[],personality:{},race:'Orc',role:'Warrior'};
|
||||
const b={...a,id:'b',name:'B',memories:[],relationships:[]};
|
||||
const state={revision:0,sequence:0,events:[],bots:[a,b],settings:{provider:'ollama',model:'test',brains:{enabled:false,residentMemoryLimit:5,residentMaxTokens:100}}};
|
||||
const store={load:async()=>state,save:async()=>{}};
|
||||
const request={id:'social-test',createdAt:new Date().toISOString(),socialTurn:0,speakerName:'B',selectedPlayer:'A',message:'Initiate',channel:'say',nearbyBots:['B']};
|
||||
let pending=request,deliveries=[],followups=0,source='';
|
||||
queue.pendingDeliveries=async()=>deliveries;
|
||||
queue.leaseConversation=async()=>{const r=pending;pending=null;return r;};
|
||||
queue.cleanupConversations=async()=>{};
|
||||
queue.completeConversation=async()=>{};
|
||||
queue.failConversation=async()=>{};
|
||||
queue.awaitDelivery=async(_db,r,botId,reply,commandId)=>{deliveries=[{request:r,botId,reply,commandId,status:'pending'}];};
|
||||
queue.queueSocialReply=async(_db,r,name,reply)=>{if(r.socialTurn===0){followups++;pending={...r,id:r.id+':reply',socialTurn:1,speakerName:name,selectedPlayer:'B',message:reply};}};
|
||||
ale.queueAleCommand=async(_db,s)=>{source=s;return {id:'cmd'};};
|
||||
const originalFetch=global.fetch;
|
||||
global.fetch=async()=>({ok:true,json:async()=>({message:{content:'{"reply":"How is the hunt going?"}'}})});
|
||||
try{
|
||||
await runConversationTick(store,{}, {LLM_URL:'http://model'});
|
||||
assert.match(source,/GetDistance\(peer\)>25/);
|
||||
assert.match(source,/GetTeam/);
|
||||
assert.equal(a.memories.length,0);
|
||||
deliveries[0].status='completed';
|
||||
await runConversationTick(store,{}, {LLM_URL:'http://model'});
|
||||
assert.equal(followups,1);assert.equal(a.memories.length,0);
|
||||
deliveries[0].status='completed';
|
||||
await runConversationTick(store,{},{});
|
||||
assert.equal(a.memories.length,1);assert.equal(b.memories.length,1);
|
||||
assert.equal(a.relationships[0].targetId,'b');assert.equal(b.relationships[0].targetId,'a');
|
||||
await runConversationTick(store,{},{});
|
||||
assert.equal(a.memories.length,1);assert.equal(b.memories.length,1);assert.equal(followups,1);
|
||||
}finally{global.fetch=originalFetch;}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user