Expand 35 modules across encoding, consensus, experimental, messaging, pear, storage, and supercomputer APIs.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-21 03:46:02 -04:00
co-authored by Cursor
parent 5097df5c22
commit ff129d56b0
35 changed files with 237 additions and 2 deletions
@@ -382,6 +382,16 @@ class HyperP2PTaskOrchestrator extends EventEmitter {
return n return n
} }
async clearAll () {
const cancelled = await this.cancelAllPending()
const tasks = this.tasks.size
this.tasks.clear()
this.results.clear()
this.dependencies.clear()
this.reverseDeps.clear()
return { cancelled, tasks }
}
async queryTasks (filter = {}) { async queryTasks (filter = {}) {
await this.ready() await this.ready()
let results = Array.from(this.tasks.values()) let results = Array.from(this.tasks.values())
@@ -135,6 +135,10 @@ class HyperP2PLeaderLease extends EventEmitter {
return true return true
} }
clearAll () {
return this.resetLease()
}
_gossipSync () { _gossipSync () {
gossipSend(this, { gossipSend(this, {
type: 'leader-lease-sync', type: 'leader-lease-sync',
@@ -336,6 +336,18 @@ class HyperP2PPresence extends EventEmitter {
return [...this.peers.keys()] return [...this.peers.keys()]
} }
clearAll () {
const selfKey = b4a.toString(this.keyPair.publicKey, 'hex')
let n = 0
for (const id of this.peerIds()) {
if (id !== selfKey) {
this.peers.delete(id)
n++
}
}
return n
}
announceNow () { announceNow () {
this._broadcastPresence() this._broadcastPresence()
return this.getSelf() return this.getSelf()
@@ -77,6 +77,10 @@ class HyperP2PSessionBridge extends EventEmitter {
return n return n
} }
async clearAll () {
return this.removeAllPairs()
}
async removePair (token) { async removePair (token) {
const entry = this._tokens.get(token) const entry = this._tokens.get(token)
if (!entry) return false if (!entry) return false
@@ -77,6 +77,10 @@ class HyperP2PCompactCodecBridge extends EventEmitter {
return this._stats return this._stats
} }
clearAll () {
return this.resetStats()
}
getStats () { getStats () {
return { return {
...this._stats, ...this._stats,
@@ -109,6 +109,10 @@ class HyperP2PMessageEnvelope extends EventEmitter {
return this._stats return this._stats
} }
clearAll () {
return this.resetStats()
}
getStats () { getStats () {
return { ...this._stats, protocol: PROTOCOL } return { ...this._stats, protocol: PROTOCOL }
} }
@@ -120,6 +120,15 @@ class HyperP2PContradictionGraph extends EventEmitter {
return n return n
} }
clearAll () {
return this.clear()
}
claimBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.claim(e.subject, e.predicate, e.value))
}
claimIds () { claimIds () {
return this._claims.map((c) => c.id) return this._claims.map((c) => c.id)
} }
@@ -118,6 +118,15 @@ class HyperP2PMirrorRealm extends EventEmitter {
return { realmA: this.clearRealm('A'), realmB: this.clearRealm('B') } return { realmA: this.clearRealm('A'), realmB: this.clearRealm('B') }
} }
clearAll () {
return this.clearBoth()
}
writeBatch (realm, entries) {
if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.write(realm, e.key, e.value))
}
hasDiff (key) { hasDiff (key) {
return this.diffKeys().includes(String(key)) return this.diffKeys().includes(String(key))
} }
@@ -87,6 +87,11 @@ class HyperP2PPhaseShiftClock extends EventEmitter {
return n return n
} }
clearAll () {
this.resetPhase()
return this.clearPeerPhases()
}
getPeerPhase (peer) { getPeerPhase (peer) {
return this._peerPhases.get(peer) ?? null return this._peerPhases.get(peer) ?? null
} }
@@ -85,6 +85,15 @@ class HyperP2PSilenceProtocol extends EventEmitter {
return n return n
} }
clearAll () {
return this.clear()
}
assertAbsentBatch (ids) {
if (!Array.isArray(ids)) throw new Error('ids array required')
return ids.map((id) => this.assertAbsent(id))
}
revokeAbsent (id) { revokeAbsent (id) {
return this._absent.delete(String(id)) return this._absent.delete(String(id))
} }
@@ -110,6 +110,10 @@ class HyperP2PBucketRateLimit extends EventEmitter {
return this._buckets.delete(key) return this._buckets.delete(key)
} }
clearAll () {
return this.reset()
}
lowestTokens () { lowestTokens () {
let worst = null let worst = null
for (const [peerId, b] of this._buckets) { for (const [peerId, b] of this._buckets) {
@@ -81,6 +81,10 @@ class HyperP2PAdaptiveStreamingEngine extends EventEmitter {
return this._recommendation return this._recommendation
} }
clearAll () {
return this.reset()
}
bufferMs () { bufferMs () {
return this._bufferMs return this._bufferMs
} }
@@ -101,6 +101,10 @@ class HyperP2PContentProtection extends EventEmitter {
return n return n
} }
clearAll () {
return this.clearKeys()
}
getStats () { getStats () {
return mediaStats(this._stats, PROTOCOL, { activeKeyId: this._activeKeyId, keys: this._keys.size }) return mediaStats(this._stats, PROTOCOL, { activeKeyId: this._activeKeyId, keys: this._keys.size })
} }
@@ -362,6 +362,13 @@ class HyperP2PDistributedEventBus extends EventEmitter {
return n return n
} }
clearAll () {
const seen = this.clearSeenEvents()
const subs = this.unsubscribeAll()
this.eventLog.clear()
return { seen, subs }
}
async publishBatch (events) { async publishBatch (events) {
if (!Array.isArray(events)) throw new Error('events array required') if (!Array.isArray(events)) throw new Error('events array required')
const out = [] const out = []
@@ -138,9 +138,14 @@ class HyperP2PGossipMesh extends EventEmitter {
const n = this._seen.size const n = this._seen.size
this._seen.clear() this._seen.clear()
this._seenAt.clear() this._seenAt.clear()
this._recent = []
return n return n
} }
clearAll () {
return this.clearSeen()
}
hasSeen (id) { hasSeen (id) {
return this._seen.has(String(id)) return this._seen.has(String(id))
} }
@@ -53,6 +53,10 @@ class HyperP2PRetainedMessages extends EventEmitter {
return ok return ok
} }
clearAll () {
return this.clear()
}
channelCount () { channelCount () {
return this._store.size return this._store.size
} }
@@ -102,6 +102,12 @@ class HyperP2PTopicChannel extends EventEmitter {
return channels.length return channels.length
} }
clearAll () {
const subs = this.unsubscribeAll()
const retained = this.clearRetained()
return { subs, retained }
}
retainedChannels () { retainedChannels () {
return [...this._retained.keys()] return [...this._retained.keys()]
} }
@@ -81,6 +81,10 @@ class HyperP2PConnectionPool extends EventEmitter {
return n return n
} }
clearAll () {
return this.closeAll()
}
_sweepIdle () { _sweepIdle () {
const now = Date.now() const now = Date.now()
for (const [id, lane] of this._lanes) { for (const [id, lane] of this._lanes) {
@@ -83,6 +83,10 @@ class HyperP2PProtocolHandshake extends EventEmitter {
return n return n
} }
clearAll () {
return { offers: this.clearOffers(), agreed: this.clearAgreed() }
}
getStats () { getStats () {
return { ...this._stats, pending: this._offers.size, agreed: this._agreed.size, protocol: PROTOCOL } return { ...this._stats, pending: this._offers.size, agreed: this._agreed.size, protocol: PROTOCOL }
} }
@@ -122,6 +122,15 @@ class HyperBareEntryRunner extends EventEmitter {
return n return n
} }
clearAll () {
return this.clearRuns()
}
planRunBatch (specs) {
if (!Array.isArray(specs)) throw new Error('specs array required')
return specs.map((s) => this.planRun(s.target, s.args || [], s.flags || {}))
}
cancelAllRuns () { cancelAllRuns () {
let n = 0 let n = 0
for (const id of this.runIds()) { for (const id of this.runIds()) {
+3 -2
View File
@@ -87,8 +87,9 @@ class HyperBareImportMap extends EventEmitter {
return n return n
} }
has (specifier) { setBatch (entries) {
return Object.prototype.hasOwnProperty.call(this._imports, String(specifier)) if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.set(e.specifier, e.target))
} }
entryCount () { entryCount () {
@@ -65,6 +65,11 @@ class HyperPearDevProfile extends EventEmitter {
return this.snapshot() return this.snapshot()
} }
clearAll () {
this.disableDev()
return this.resetFlags()
}
mergeArgv (argvBridge) { mergeArgv (argvBridge) {
if (!argvBridge || typeof argvBridge.hasFlag !== 'function') { if (!argvBridge || typeof argvBridge.hasFlag !== 'function') {
throw new Error('argv bridge required') throw new Error('argv bridge required')
@@ -62,6 +62,10 @@ class HyperPearLinkResolver extends EventEmitter {
return n return n
} }
clearAll () {
return this.clearCache()
}
normalize (parts) { normalize (parts) {
const href = this.serialize(parts) const href = this.serialize(parts)
return this.parse(href) return this.parse(href)
@@ -74,6 +74,10 @@ class HyperPearRuntimeEmbed extends EventEmitter {
return true return true
} }
clearAll () {
return this.reset()
}
snapshot () { snapshot () {
return { return {
dir: this.dir, dir: this.dir,
@@ -115,6 +115,17 @@ class HyperP2PCircuitBreaker extends EventEmitter {
return ids.length return ids.length
} }
clearAll () {
const n = this._circuits.size
this._circuits.clear()
return n
}
registerBatch (ids) {
if (!Array.isArray(ids)) throw new Error('ids array required')
return ids.map((id) => this.register(id))
}
closedCount () { closedCount () {
let n = 0 let n = 0
for (const c of this._circuits.values()) { for (const c of this._circuits.values()) {
@@ -73,6 +73,15 @@ class HyperP2PRetryPolicy extends EventEmitter {
return n return n
} }
clearAll () {
return this.clearRoutes()
}
registerRouteBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.registerRoute(e.id, e.opts || {}))
}
getRoute (id) { getRoute (id) {
const r = this._routes.get(String(id)) const r = this._routes.get(String(id))
return r ? { ...r } : null return r ? { ...r } : null
@@ -98,6 +98,12 @@ class HyperP2PAutobaseIndexerBus extends EventEmitter {
return n return n
} }
clearAll () {
const events = this.clearEvents()
const subs = this.unsubscribeAll()
return { events, subs }
}
subscriberCount () { subscriberCount () {
return this._subs.size return this._subs.size
} }
@@ -95,6 +95,14 @@ class HyperP2PAutobaseLightWriter extends EventEmitter {
return this.flushOps() return this.flushOps()
} }
clearPending () {
return this.rollbackOps()
}
clearAll () {
return this.clearPending()
}
getStats () { getStats () {
return autobaseStats(this._stats, PROTOCOL, { return autobaseStats(this._stats, PROTOCOL, {
pending: this._ops.length, pending: this._ops.length,
@@ -52,6 +52,10 @@ class HyperP2PBeeRangeWatch extends EventEmitter {
return n return n
} }
clearAll () {
return this.unwatchAll()
}
emitChange (key, value, op = 'put') { emitChange (key, value, op = 'put') {
if (key == null) throw new Error('key required') if (key == null) throw new Error('key required')
let n = 0 let n = 0
@@ -64,6 +64,15 @@ class HyperP2PDriveWatchNotify extends EventEmitter {
return n return n
} }
clearAll () {
return this.unwatchAll()
}
watchPathBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.watchPath(e.path, e.cb))
}
hasWatch (id) { hasWatch (id) {
return this._watches.has(id) return this._watches.has(id)
} }
@@ -122,6 +122,15 @@ class HyperP2PBandwidthShare extends EventEmitter {
return n return n
} }
clearAll () {
return this.clearOffers()
}
offerBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.offer(e.peerId, e.upMbps, e.downMbps))
}
async ready () { async ready () {
if (this.swarm || !this.topic) return this if (this.swarm || !this.topic) return this
await initModuleSwarm(this, { await initModuleSwarm(this, {
@@ -303,6 +303,20 @@ class HyperP2PClusterFabric extends EventEmitter {
return ok return ok
} }
clearAll () {
const nodes = this._nodes.size
const reservations = this._reservations.size
for (const id of [...this._nodes.keys()]) this.removeNode(id)
this._reservations.clear()
this._used = { cpuMs: 0, ramMb: 0, gpuSlots: 0, diskGb: 0 }
return { nodes, reservations }
}
publishNodeBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.publishNode(e.resources || {}, e.peerId))
}
/** /**
* Check if the combined cluster can satisfy a workload without reserving. * Check if the combined cluster can satisfy a workload without reserving.
*/ */
@@ -110,6 +110,18 @@ class HyperP2PNetGateway extends EventEmitter {
return Math.max(0, gw.maxBytes - (this._usage.get(id) || 0)) return Math.max(0, gw.maxBytes - (this._usage.get(id) || 0))
} }
clearAll () {
const gateways = this._gateways.size
this._gateways.clear()
this._usage.clear()
return gateways
}
registerGatewayBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.registerGateway(e.peerId, e.caps || {}))
}
async ready () { async ready () {
if (this.swarm || !this.topic) return this if (this.swarm || !this.topic) return this
await initModuleSwarm(this, { await initModuleSwarm(this, {
@@ -81,6 +81,15 @@ class HyperP2PKeyRotation extends EventEmitter {
return n return n
} }
clearAll () {
return this.revokeAll()
}
scheduleRotationBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.scheduleRotation(e.keyId, e.newMaterial, e.activateAt))
}
nextActivation (keyId) { nextActivation (keyId) {
const list = this._pending.get(String(keyId)) || [] const list = this._pending.get(String(keyId)) || []
if (!list.length) return null if (!list.length) return null
@@ -83,6 +83,15 @@ class HyperP2PSessionRotation extends EventEmitter {
return ids.length return ids.length
} }
clearAll () {
return this.revokeAll()
}
rotateSessionBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.rotateSession(e.sessionId, e.newToken))
}
_gossip (data) { _gossip (data) {
if (!this._peerMsgs) return if (!this._peerMsgs) return
gossipSend(this, data) gossipSend(this, data)