Phase 957: gossip outbox stats build extract (v0.8.924)

Add guild-mesh-gossip-outbox-stats-build with lane alert thresholds,
outbox stats resolve, and replication diagnostics gossip slice. Gossip
view and partition-heal mixins delegate without behavior change.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-06-04 23:13:43 -04:00
co-authored by Cursor
parent eb5f18fba5
commit d70925d4fc
4 changed files with 79 additions and 34 deletions
@@ -1,38 +1,18 @@
'use strict'
const { getListingTtlMs } = require('pearcord-discovery')
const {
buildGossipLaneAlertThresholds,
buildGossipLaneAlertsFromCounts
} = require('../../../guild-mesh-gossip-outbox-stats-build')
const platformGuildSyncGossipViewMixin = {
_gossipLaneAlertThresholds () {
return {
message: Math.max(
8,
Number(process.env.PEARCORD_GOSSIP_LANE_ALERT_MESSAGE) || 48
),
presence: Math.max(
8,
Number(process.env.PEARCORD_GOSSIP_LANE_ALERT_PRESENCE) || 32
),
audit: Math.max(8, Number(process.env.PEARCORD_GOSSIP_LANE_ALERT_AUDIT) || 24),
default: Math.max(8, Number(process.env.PEARCORD_GOSSIP_LANE_ALERT_DEFAULT) || 16)
}
return buildGossipLaneAlertThresholds()
},
_gossipLaneAlertsFromCounts (laneCounts = {}) {
const thresholds = this._gossipLaneAlertThresholds()
const alerts = []
for (const lane of ['message', 'presence', 'audit', 'default']) {
const count = Number(laneCounts[lane]) || 0
const threshold = thresholds[lane] || 16
if (count < threshold) continue
alerts.push({
lane,
count,
threshold,
severity: count >= threshold * 2 ? 'high' : 'warn'
})
}
return alerts
return buildGossipLaneAlertsFromCounts(laneCounts, this._gossipLaneAlertThresholds())
},
_sparseAckSyncRowsForView (guildId) {
@@ -28,6 +28,11 @@ const {
id, now, guildTopic
} = require('../../../platform-class-imports')
const { buildMeshStabilityStatsSnapshot } = require('../../../guild-mesh-stability-stats-build')
const {
resolveGossipOutboxStats,
resolveGossipLaneCounts,
buildGossipOutboxDiagnosticsSlice
} = require('../../../guild-mesh-gossip-outbox-stats-build')
/** Phase 756 — partition heal orchestration */
@@ -968,11 +973,8 @@ getMeshStabilityStats (guildId) {
if (!id) return null
const health = this.getGuildSyncHealth(id)
const bw = this._guildSyncBandwidthWindow
const gossipStats = this._guildGossipOutbox.stats?.() || {
size: this._guildGossipOutbox.size,
dropCount: 0
}
const gossipLaneCounts = this._guildGossipOutbox.laneCounts?.() || null
const gossipStats = resolveGossipOutboxStats(this._guildGossipOutbox)
const gossipLaneCounts = resolveGossipLaneCounts(this._guildGossipOutbox)
const gossipLaneAlerts = gossipLaneCounts
? this._gossipLaneAlertsFromCounts(gossipLaneCounts)
: []
@@ -1031,9 +1033,7 @@ exportMeshReplicationDiagnostics (guildId) {
sparseAckGuildIds: [...this._sparseAckCursorByGuild.keys()],
channelReplication,
maxReplicationLagMs: maxLagMs,
gossipOutbox: this._guildGossipOutbox.stats?.() || null,
gossipReplay: this._guildGossipOutbox.replayStats?.() || null,
gossipLaneCounts: this._guildGossipOutbox.laneCounts?.() || null,
...buildGossipOutboxDiagnosticsSlice(this._guildGossipOutbox),
guildTopicPool: this._guildTopicPool?.snapshot?.() || null,
meshAutoHeal: {
zeroPeerSince: this._meshZeroPeerSinceByGuild.get(id) || null,