From 1f9ad52d07fb3090aba519f9cdde3d8b19b86725 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 25 Sep 2026 13:30:52 +0800 Subject: [PATCH] Allow telemetry cadence jitter in sampled bot hours --- core/realm-insights.ts | 2 +- tests/realm-insights.test.cjs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/realm-insights.ts b/core/realm-insights.ts index 48fc5f4..1fd7719 100644 --- a/core/realm-insights.ts +++ b/core/realm-insights.ts @@ -18,7 +18,7 @@ export function observeInsights(s:State,previous:Cursor|undefined,now:number){ const partyKey=fresh&&w!.groupId&&peers.length?[b.name,...peers].sort().join('|'):undefined; const nearPartyKey=partyKey&&peers.some(n=>(w!.nearby??[]).includes(n))?partyKey:undefined; const elapsed=previous?now-previous.at:0; - if(old&&fresh&&w!.at>(old.worldAt??0)&&elapsed>0&&elapsed<=120){ + if(old&&fresh&&w!.at>(old.worldAt??0)&&elapsed>0&&elapsed<=180){ if(b.status==='online'&&old.status==='online'){add(`online-time:${b.id}:${now}`,'onlineSeconds',b.name,elapsed,'Fresh consecutive online observations, including recovery time');if(!w!.isDead&&!w!.isGhost&&(moved||w!.inCombat||w!.casting))add(`active-time:${b.id}:${now}`,'activeSeconds',b.name,elapsed,'Sampled movement, combat or casting; not proof of useful progress');} if(partyKey&&partyKey===old.partyKey)add(`party-time:${b.id}:${now}`,'groupedSeconds',b.name,elapsed,'Sampled seconds in the same living party'); if(nearPartyKey&&nearPartyKey===old.nearPartyKey)add(`party-near:${b.id}:${now}`,'nearPartySeconds',b.name,elapsed,'Sampled seconds with a party member within 35 yards'); diff --git a/tests/realm-insights.test.cjs b/tests/realm-insights.test.cjs index a14518d..9d06436 100644 --- a/tests/realm-insights.test.cjs +++ b/tests/realm-insights.test.cjs @@ -43,6 +43,8 @@ test('exposure excludes stale snapshots and gaps; outcome evidence counts once', assert.equal(next.events.filter(e=>e.kind==='onlineSeconds').reduce((n,e)=>n+e.amount,0),120); assert.equal(next.events.filter(e=>e.kind==='intentObserved').length,1); assert.equal(observeInsights(s,next.cursor,now+90).events.length,0); + for(const b of s.bots)b.world.at=now+185; + assert.equal(observeInsights(s,next.cursor,now+185).events.filter(e=>e.kind==='onlineSeconds').reduce((n,e)=>n+e.amount,0),250); for(const b of s.bots)b.world.at=now+600; assert.equal(observeInsights(s,next.cursor,now+600).events.filter(e=>e.kind==='onlineSeconds').length,0); });