feat(observability,encoding,network,pubsub): expand support category modules
Hyper-P2P Module Tests / unit-all (push) Has been cancelled

- stats-exporter: snapshot history, compare, filter
- health-probe: unhealthyPeers, averageRtt, pruneStale
- schema-validator: assertValid, validateBatch, maxLength rules
- compact-codec-bridge: encodeBatch, listCodecs
- discovery-health: topPeers, pruneStale, averageRtt
- peer-bootstrap-store: removeBootstrap, findByHint
- retained-messages: retainBatch, totalRetained, channelCount
- ci: restore flat-repo production test workflow

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-21 02:18:17 -04:00
co-authored by Cursor
parent 3e1c353ade
commit cd048cb8c8
8 changed files with 249 additions and 28 deletions
@@ -24,6 +24,11 @@ class HyperP2PRetainedMessages extends EventEmitter {
return entry
}
retainBatch (channel, items) {
if (!Array.isArray(items)) throw new Error('items must be an array')
return items.map((item) => this.retain(channel, item.payload, item.meta || {}))
}
latest (channel) {
const list = this._store.get(channel)
if (!list || !list.length) return null
@@ -33,34 +38,56 @@ class HyperP2PRetainedMessages extends EventEmitter {
list (channel, limit = 10) {
const list = this._store.get(channel) || []
return list.slice(-limit)
return list.slice(-Math.max(0, limit | 0))
}
clear (channel) {
if (channel == null) {
const n = this._store.size
this._store.clear()
this._stats.cleared++
return true
this._stats.cleared += n
return n
}
const ok = this._store.delete(channel)
if (ok) this._stats.cleared++
return ok
}
listChannels () { return [...this._store.keys()] }
channelCount () {
return this._store.size
}
hasChannel (channel) { return this._store.has(channel) }
totalRetained () {
let n = 0
for (const list of this._store.values()) n += list.length
return n
}
listChannels () {
return [...this._store.keys()]
}
hasChannel (channel) {
return this._store.has(channel)
}
getStats () {
return {
...this._stats,
channels: this._store.size,
total: this.totalRetained(),
protocol: PROTOCOL
}
}
async ready () { return this }
async close () { this._store.clear() }
async ready () {
return this
}
async close () {
this._store.clear()
this.emit('closed')
}
}
module.exports = { HyperP2PRetainedMessages, PROTOCOL }