Allow telemetry cadence jitter in sampled bot hours
Core tests / core (push) Successful in 31s

This commit is contained in:
Codex
2026-09-25 13:30:52 +08:00
parent 502cb1e4fd
commit 1f9ad52d07
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -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 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 nearPartyKey=partyKey&&peers.some(n=>(w!.nearby??[]).includes(n))?partyKey:undefined;
const elapsed=previous?now-previous.at:0; 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(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(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'); if(nearPartyKey&&nearPartyKey===old.nearPartyKey)add(`party-near:${b.id}:${now}`,'nearPartySeconds',b.name,elapsed,'Sampled seconds with a party member within 35 yards');
+2
View File
@@ -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==='onlineSeconds').reduce((n,e)=>n+e.amount,0),120);
assert.equal(next.events.filter(e=>e.kind==='intentObserved').length,1); assert.equal(next.events.filter(e=>e.kind==='intentObserved').length,1);
assert.equal(observeInsights(s,next.cursor,now+90).events.length,0); 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; 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); assert.equal(observeInsights(s,next.cursor,now+600).events.filter(e=>e.kind==='onlineSeconds').length,0);
}); });