feat(supercomputer,experimental): expand thermal, RAM, disk, paradox APIs

Thermal hottest peer and sample clear, RAM pool reset, disk stripe
missing shards, paradox clock/merge helpers, mycelium top donors.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-21 02:33:33 -04:00
co-authored by Cursor
parent d285079522
commit 84bc18bc6e
7 changed files with 78 additions and 0 deletions
@@ -84,6 +84,17 @@ class HyperP2PMyceliumPool extends EventEmitter {
} }
} }
topDonors (n = 5) {
return [...this._balances.entries()]
.sort((a, b) => b[1] - a[1])
.slice(0, n)
.map(([peerId, balance]) => ({ peerId, balance }))
}
resetPeer (peerId) {
return this._balances.delete(this._pid(peerId))
}
async ready () { async ready () {
if (this.swarm || !this.topic) return this if (this.swarm || !this.topic) return this
await initModuleSwarm(this, { await initModuleSwarm(this, {
@@ -84,6 +84,18 @@ class HyperP2PParadoxClock extends EventEmitter {
return { stamps: [...this._stamps.values()] } return { stamps: [...this._stamps.values()] }
} }
clearStamp (eventId) {
return this._stamps.delete(String(eventId))
}
logicalClock () {
return this._logical
}
stampCount () {
return this._stamps.size
}
async ready () { async ready () {
if (this.swarm || !this.topic) return this if (this.swarm || !this.topic) return this
await initModuleSwarm(this, { await initModuleSwarm(this, {
@@ -61,6 +61,14 @@ class HyperP2PParadoxMerge extends EventEmitter {
return [...this._branches.keys()].filter((id) => !this._resolved.has(id)) return [...this._branches.keys()].filter((id) => !this._resolved.has(id))
} }
clearBranches (id) {
return this._branches.delete(String(id))
}
resolvedCount () {
return this._resolved.size
}
_gossip (data) { _gossip (data) {
if (!this._peerMsgs) return if (!this._peerMsgs) return
gossipSend(this, data) gossipSend(this, data)
@@ -97,6 +97,12 @@ class HyperP2PPheromoneTrail extends EventEmitter {
return this._trails.delete(String(pathId)) return this._trails.delete(String(pathId))
} }
setEvaporationRate (rate) {
if (rate <= 0 || rate > 1) throw new Error('rate must be in (0,1]')
this.evaporationRate = rate
return this.evaporationRate
}
async ready () { async ready () {
if (this.swarm || !this.topic) return this if (this.swarm || !this.topic) return this
await initModuleSwarm(this, { await initModuleSwarm(this, {
@@ -111,6 +111,20 @@ class HyperP2PDiskStripe extends EventEmitter {
return stripe.shards.size / stripe.pathCount return stripe.shards.size / stripe.pathCount
} }
dropStripe (stripeId) {
return this._stripes.delete(String(stripeId))
}
missingShards (stripeId) {
const stripe = this._stripes.get(stripeId)
if (!stripe) return []
const out = []
for (let i = 0; i < stripe.pathCount; i++) {
if (!stripe.shards.has(i)) out.push(i)
}
return out
}
getStats () { getStats () {
return clusterStats(this._stats, PROTOCOL, { return clusterStats(this._stats, PROTOCOL, {
open: this._stripes.size, open: this._stripes.size,
+10
View File
@@ -85,6 +85,16 @@ class HyperP2PRamPool extends EventEmitter {
listLeases () { return [...this._leases.values()] } listLeases () { return [...this._leases.values()] }
resetPool () {
this._pool.clear()
this._leases.clear()
this.emit('reset')
}
leaseFor (leaseId) {
return this._leases.get(String(leaseId)) || null
}
async ready () { async ready () {
if (this.swarm || !this.topic) return this if (this.swarm || !this.topic) return this
await initModuleSwarm(this, { await initModuleSwarm(this, {
@@ -90,6 +90,23 @@ class HyperP2PThermalGuard extends EventEmitter {
return { cpu: this.cpuThreshold, ram: this.ramThreshold, tempC: this.tempThresholdC } return { cpu: this.cpuThreshold, ram: this.ramThreshold, tempC: this.tempThresholdC }
} }
clearSample (peerId) {
return this._samples.delete(this._pid(peerId))
}
hottestPeer () {
let best = null
for (const s of this._samples.values()) {
const hot = s.cpuPct + s.ramPct + (s.tempC / 2)
if (!best || hot > best.hot) best = { peerId: s.peerId, hot, sample: s }
}
return best
}
sampleCount () {
return this._samples.size
}
async ready () { async ready () {
if (this.swarm || !this.topic) return this if (this.swarm || !this.topic) return this
await initModuleSwarm(this, { await initModuleSwarm(this, {