mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 04:11:35 +00:00
Change-detectors, tautologies, source-reading tests, redundant duplicates, mock-echo tests and dead/unrunnable tests. Per-test rationale in the lane ledger (category + reason for every removal).
45 lines
1.7 KiB
TypeScript
45 lines
1.7 KiB
TypeScript
import assert from 'node:assert/strict'
|
|
|
|
import { test } from 'vitest'
|
|
|
|
import { createAmbientClaimArbiter, createEventDeduper } from './event-dedupe'
|
|
|
|
test('collapses the same key inside the window (two windows, one event)', () => {
|
|
const isDup = createEventDeduper(1000)
|
|
|
|
assert.equal(isDup('input:s1', 0), false, 'first window claims')
|
|
assert.equal(isDup('input:s1', 5), true, 'second window is deduped')
|
|
})
|
|
|
|
test('distinct keys are independent', () => {
|
|
const isDup = createEventDeduper(1000)
|
|
|
|
assert.equal(isDup('input:s1', 0), false)
|
|
assert.equal(isDup('approval:s1', 0), false, 'different kind')
|
|
assert.equal(isDup('input:s2', 0), false, 'different session')
|
|
})
|
|
|
|
test('re-fires once the window elapses', () => {
|
|
const isDup = createEventDeduper(1000)
|
|
|
|
assert.equal(isDup('turnDone:s1', 0), false)
|
|
assert.equal(isDup('turnDone:s1', 999), true, 'still within window')
|
|
assert.equal(isDup('turnDone:s1', 1000), false, 'window elapsed → fires again')
|
|
})
|
|
|
|
// #99717: the hidden app window under an open HUD claims the same reply late.
|
|
test('a spoken reply stays claimed long after the tick window, a beep does not', () => {
|
|
const owns = createAmbientClaimArbiter(1000)
|
|
|
|
assert.equal(owns('speak:m1', 0), true, 'HUD renderer claims the reply')
|
|
assert.equal(owns('speak:m1', 5_000), false, 'app window claiming 5 s later stays quiet')
|
|
assert.equal(owns('sound:turnDone:s1', 0), true)
|
|
assert.equal(owns('sound:turnDone:s1', 5_000), true, 'beep keys still re-fire after the tick window')
|
|
})
|
|
|
|
test('a spoken reply can be claimed again once the speech TTL elapses', () => {
|
|
const owns = createAmbientClaimArbiter(1000, 60_000)
|
|
|
|
assert.equal(owns('speak:m1', 0), true)
|
|
assert.equal(owns('speak:m1', 60_000), true)
|
|
})
|