Files
modules/pear-platform/hyper-pear-update-gossip
Raven ScottandCursor 3af23c0d34 Add toJSON() serialization helpers across all module categories on main.
Fourth pass: toJSON() delegates to snapshot() (or exportSnapshot/stateSnapshot) for JSON export and logging across agents, applications, consensus, core, encoding, experimental, indexes, media, messaging, network, observability, pear-platform, routing, scheduling, storage, supercomputer, trust, measurement, oracles, and time-ordering modules.

Co-authored-by: Cursor <[email protected]>
2026-05-21 04:22:54 -04:00
..
2026-05-20 22:56:32 -04:00
2026-05-21 00:07:44 -04:00
2026-05-20 21:57:50 -04:00
2026-05-20 21:57:50 -04:00
2026-05-20 23:36:32 -04:00

hyper-pear-update-gossip

Publish Pear app updates (version + manifest); keep lexicographically greatest version as latest; notify subscribers.

Category: pear-platform · Protocol: pear-update-gossip/v1 · Exports: HyperPearUpdateGossip, HyperP2PPearUpdateGossip, PROTOCOL

When to use

Mesh-wide “latest build” discovery for Pear apps.

When not to use

Semver-aware updates (versions compared as strings with >).

Quick start

const { HyperPearUpdateGossip } = require('hyper-pear-update-gossip')
const gossip = new HyperPearUpdateGossip({ topic: 'updates' })
await gossip.ready()
gossip.publishUpdate('1.0.1', { url: 'pear://bundle/app' })
console.log(gossip.latestUpdate())
await gossip.close()

Docs

Test

npm test

API

Member Description
new HyperPearUpdateGossip(opts?) topic, keyPair.
publishUpdate(version, manifest) manifest object; updates _latest if version greater.
latestUpdate() Copy of latest or null.
subscribe(fn) Called immediately with latest if present; returns unsubscribe.
getStats() { published, gossipIn, gossipOut, subscribers, hasLatest, protocol }.
ready() / close() Clears subscribers on close.

Events: update, closed. Also invokes subscriber callbacks on new latest.

Architecture

_latest: { version, manifest, publishedAt } | null
_subs: Set<fn>
Gossip update-publish: adopt if d.version > _latest.version (string compare)

Use zero-padded numeric versions if ordering matters ("009" vs "10").

Wire table

type Fields Direction
update-publish version, manifest, publishedAt Any → all

Errors

  • Non-object manifest or empty version on publishUpdate.
  • subscribe(fn): fn must be a function.

Composition

  • Manifest often matches hyper-bare-bundle-bridge resolve output.
  • Multisig gate: hyper-p2p-multisig-threshold before publishUpdate.
  • String version compare—use fixed-width numeric strings if needed.

Example

const { HyperPearUpdateGossip } = require('hyper-pear-update-gossip')

const gossip = new HyperPearUpdateGossip({ topic: process.argv[2] })
const unsub = gossip.subscribe((u) => console.log('latest', u.version))

await gossip.ready()
gossip.publishUpdate('1.0.1', { url: 'pear://bundle/app' })
console.log(gossip.latestUpdate())
unsub()
await gossip.close()