Add features across agents, collab, trust, indexes, and hyperbee.

Manual pass: task cancelTask, workflow topologicalOrder/fail/reset, collab kick/replay, trust trustedPeers and multisig TTL sweep, graph shortestPath, inverted topTerms, dedup filterNew, bee notifyBatch/seekVersion — all with tests.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-21 01:04:42 -04:00
co-authored by Cursor
parent cb9caad46c
commit b8b815fce6
25 changed files with 386 additions and 6 deletions
@@ -102,6 +102,39 @@ class HyperP2PTrustGraph extends EventEmitter {
return nodes.size
}
listNeighbors (from) {
const f = typeof from === 'string' ? from : b4a.toString(from, 'hex')
const m = this._edges.get(f)
return m ? [...m.keys()] : []
}
removeEdge (from, to) {
const f = typeof from === 'string' ? from : b4a.toString(from, 'hex')
const t = typeof to === 'string' ? to : b4a.toString(to, 'hex')
const m = this._edges.get(f)
if (!m || !m.has(t)) return false
m.delete(t)
if (!m.size) this._edges.delete(f)
this.emit('edge-removed', { from: f, to: t })
return true
}
trustedPeers (from, minScore = 0.5) {
const f = typeof from === 'string' ? from : b4a.toString(from, 'hex')
const candidates = new Set()
for (const edge of this.edges()) {
candidates.add(edge.from)
candidates.add(edge.to)
}
const out = []
for (const peer of candidates) {
if (peer === f) continue
const score = this.trustScore(f, peer)
if (score >= minScore) out.push({ peer, score })
}
return out.sort((a, b) => b.score - a.score)
}
toJSON () {
return { edges: this.edges(), decay: this.decay }
}
@@ -10,6 +10,18 @@ test('trust-graph: edge and score', async (t) => {
await g.close()
})
test('trust-graph: neighbors and trustedPeers', async (t) => {
const g = new HyperP2PTrustGraph()
g.addEdge('a', 'b', 0.9)
t.ok(g.listNeighbors('a').includes('b'))
t.ok(g.removeEdge('a', 'b'))
t.is(g.listNeighbors('a').length, 0)
g.addEdge('a', 'b', 1)
const trusted = g.trustedPeers('a', 0.5)
t.ok(trusted.length >= 1)
await g.close()
})
test('trust-graph: merge', async (t) => {
const a = new HyperP2PTrustGraph()
const b = new HyperP2PTrustGraph()