Phase 900: export mesh registry root move + consolidated mesh fetch mixin (v0.8.867)

Non-breaking refactor — gossip-rpc-export-mesh-validators.js and
gossip-rpc-export-mesh-registry.js move export mesh registry to platform
root (aligned with gossip-rpc-pull-config.js); exportMeshFetchConfig()
lookup helper; platform-export-mesh-fetch-mixin.js consolidates audit/digest
mesh fetch mixins with thin re-export shims. Default gossip v1 unchanged;
fleet v2 cutover still deferred.

Verification: test:ci-phase900, pear run boot, pearcord.log scan.
This commit is contained in:
Raven Scott
2026-06-04 19:32:15 -04:00
parent 41798b3b58
commit 3c53ffed9a
8 changed files with 158 additions and 118 deletions
+2
View File
@@ -92,6 +92,8 @@ Application facade: one `PearcordPlatform` class that wires identity, database,
**Phase 822 (v0.8.789):** Triple-peer topology via `guild-mesh-topology` + `getMeshStabilityStats`. Bundle: `npm run test:ci-phase822`.
**Phase 900 (v0.8.867):** Export mesh registry root move + consolidated mesh fetch mixin. Bundle: `npm run test:ci-phase900`.
**Phase 899 (v0.8.866):** Export mesh fetch registry + bind helper extract. Bundle: `npm run test:ci-phase899`.
**Phase 898 (v0.8.865):** Export mesh barrel + attempt/waiter/gossip-wait-build extract. Bundle: `npm run test:ci-phase898`.
+106
View File
@@ -0,0 +1,106 @@
'use strict'
const { markRpcResponse } = require('./gossip-rpc-validators')
const { withExportMeshFetchAttempt } = require('./gossip-rpc-export-mesh-attempt')
const {
resolveExportMeshFetchWaiterByPrefix,
resolveExportMeshFetchWaiterByExactKey
} = require('./gossip-rpc-export-mesh-waiter-resolve')
const { buildGuildExportMeshGossipRequestBase } = require('./gossip-rpc-export-mesh-gossip-wait-build')
const {
isValidAuditExportArchiveMeshRow,
isValidAutomationDigestSnapshotMeshRow,
formatAutomationDigestSnapshotMeshRow
} = require('./gossip-rpc-export-mesh-validators')
/** Registry entries for targeted export mesh fetch mixins (Phase 899900). */
const exportMeshFetchRegistry = {
auditExportArchive: {
pullConfigKey: 'auditExportArchive',
resolveWaiterMethod: '_resolveAuditArchiveFetchWaiter',
fetchFromMeshMethod: 'fetchAuditExportArchiveFromMesh',
fetchOnceMethod: '_fetchAuditExportArchiveFromMeshOnce',
waitersKey: '_auditArchiveFetchWaiters',
resolveWaiter: resolveExportMeshFetchWaiterByPrefix,
permissionError: 'no permission to fetch audit export archive',
notFoundMessage: 'audit export archive not found on mesh',
validateLocal: isValidAuditExportArchiveMeshRow,
waiterMode: 'append',
timeoutErrorMessage: 'audit archive fetch timed out',
getLocalRow: (platform, archiveId) => platform.deliveryReceipts.getAuditExportArchive(archiveId),
tryRpc: (platform, archiveId, opts) => platform._tryFetchAuditExportArchiveFromMeshRpc(archiveId, opts),
ingestRpc: (platform, rpc) => platform.deliveryReceipts.ingestAuditExportArchive(rpc),
formatLocalHit: async (platform, archiveId, opts) => withExportMeshFetchAttempt(
opts,
await platform.exportAuditExportArchive(archiveId, opts)
),
formatRpcHit: async (platform, archiveId, opts, rpcArch) => markRpcResponse(withExportMeshFetchAttempt(
opts,
await platform.exportAuditExportArchive(rpcArch.id || archiveId, opts)
)),
formatGossipResult: async (platform, archiveId, opts, fetched) => withExportMeshFetchAttempt(
opts,
await platform.exportAuditExportArchive(fetched.id || archiveId, opts)
),
sendGossipRequest: (platform, archiveId, opts, requestId) => {
if (platform.guild.gossipAuditExportArchiveRequest) {
platform.guild.gossipAuditExportArchiveRequest({
...buildGuildExportMeshGossipRequestBase(platform, opts, requestId),
archiveId,
attempt: Number(opts.attempt) || 0
})
}
}
},
automationDigestSnapshot: {
pullConfigKey: 'automationDigestSnapshot',
resolveWaiterMethod: '_resolveAutomationDigestSnapshotFetchWaiter',
fetchFromMeshMethod: 'fetchAutomationDigestSnapshotFromMesh',
fetchOnceMethod: '_fetchAutomationDigestSnapshotFromMeshOnce',
waitersKey: '_automationDigestSnapshotFetchWaiters',
resolveWaiter: resolveExportMeshFetchWaiterByExactKey,
permissionError: 'no permission to fetch automation digest snapshot',
notFoundMessage: 'automation digest snapshot not found on mesh',
validateLocal: isValidAutomationDigestSnapshotMeshRow,
waiterMode: 'replace',
timeoutErrorMessage: 'automation digest snapshot fetch timed out',
getLocalRow: (platform, snapshotId) =>
platform.deliveryReceipts.getAutomationDigestExportSnapshot(snapshotId),
tryRpc: (platform, snapshotId, opts) =>
platform._tryFetchAutomationDigestSnapshotFromMeshRpc(snapshotId, opts),
ingestRpc: (platform, rpc) => platform.deliveryReceipts.ingestAutomationDigestExportSnapshot(rpc),
formatLocalHit: (platform, snapshotId, opts, row) =>
formatAutomationDigestSnapshotMeshRow(row, opts),
formatRpcHit: (platform, snapshotId, opts, rpcSnap) => markRpcResponse(formatAutomationDigestSnapshotMeshRow({
id: rpcSnap.id || snapshotId,
format: rpcSnap.format,
body: rpcSnap.body,
summaryLines: rpcSnap.summaryLines,
exportedAt: rpcSnap.exportedAt
}, opts)),
formatGossipResult: (platform, snapshotId, opts, fetched) =>
formatAutomationDigestSnapshotMeshRow(fetched, opts),
sendGossipRequest: (platform, snapshotId, opts, requestId) => {
if (platform.guild.gossipAutomationDigestExportSnapshotRequest) {
platform.guild.gossipAutomationDigestExportSnapshotRequest({
...buildGuildExportMeshGossipRequestBase(platform, opts, requestId),
snapshotId
})
}
}
}
}
function exportMeshFetchConfig (name) {
const cfg = exportMeshFetchRegistry[name]
if (!cfg) return null
return { ...cfg }
}
module.exports = {
exportMeshFetchRegistry,
exportMeshFetchConfig,
isValidAuditExportArchiveMeshRow,
isValidAutomationDigestSnapshotMeshRow,
formatAutomationDigestSnapshotMeshRow
}
+22
View File
@@ -0,0 +1,22 @@
'use strict'
const { withExportMeshFetchAttempt } = require('./gossip-rpc-export-mesh-attempt')
const isValidAuditExportArchiveMeshRow = (r) => Boolean(r?.entries?.length)
const isValidAutomationDigestSnapshotMeshRow = (r) => Boolean(r?.body?.length)
function formatAutomationDigestSnapshotMeshRow (row, opts) {
return withExportMeshFetchAttempt(opts, {
snapshotId: row.id,
format: row.format,
body: row.body,
summaryLines: row.summaryLines,
exportedAt: row.exportedAt
})
}
module.exports = {
isValidAuditExportArchiveMeshRow,
isValidAutomationDigestSnapshotMeshRow,
formatAutomationDigestSnapshotMeshRow
}
+5 -1
View File
@@ -8,6 +8,8 @@ const gossipWaitBuild = require('./gossip-rpc-export-mesh-gossip-wait-build')
const fetchOnce = require('./gossip-rpc-export-mesh-fetch-once')
const waiterResolve = require('./gossip-rpc-export-mesh-waiter-resolve')
const meshBind = require('./gossip-rpc-export-mesh-bind')
const meshValidators = require('./gossip-rpc-export-mesh-validators')
const meshRegistry = require('./gossip-rpc-export-mesh-registry')
module.exports = {
...attempt,
@@ -16,5 +18,7 @@ module.exports = {
...gossipWaitBuild,
...fetchOnce,
...waiterResolve,
...meshBind
...meshBind,
...meshValidators,
...meshRegistry
}
@@ -1,11 +1,6 @@
'use strict'
const { buildGuildExportMeshFetchMixin } = require('../../../gossip-rpc-export-mesh-bind')
const { exportMeshFetchRegistry } = require('./platform-export-mesh-fetch-registry')
/** Audit export archive mesh fetch + gossip waiters (Phase 895899). */
const platformAuditExportMeshFetchMixin = buildGuildExportMeshFetchMixin(
exportMeshFetchRegistry.auditExportArchive
)
const { platformAuditExportMeshFetchMixin } = require('./platform-export-mesh-fetch-mixin')
/** Audit export archive mesh fetch + gossip waiters (Phase 895900). */
module.exports = { platformAuditExportMeshFetchMixin }
@@ -1,11 +1,6 @@
'use strict'
const { buildGuildExportMeshFetchMixin } = require('../../../gossip-rpc-export-mesh-bind')
const { exportMeshFetchRegistry } = require('./platform-export-mesh-fetch-registry')
/** Automation digest snapshot mesh fetch + gossip waiters (Phase 895899). */
const platformAutomationDigestMeshFetchMixin = buildGuildExportMeshFetchMixin(
exportMeshFetchRegistry.automationDigestSnapshot
)
const { platformAutomationDigestMeshFetchMixin } = require('./platform-export-mesh-fetch-mixin')
/** Automation digest snapshot mesh fetch + gossip waiters (Phase 895900). */
module.exports = { platformAutomationDigestMeshFetchMixin }
@@ -0,0 +1,17 @@
'use strict'
const { buildGuildExportMeshFetchMixin } = require('../../../gossip-rpc-export-mesh-bind')
const { exportMeshFetchRegistry } = require('../../../gossip-rpc-export-mesh-registry')
/** Consolidated export mesh fetch mixins from registry entries (Phase 900). */
const platformAuditExportMeshFetchMixin = buildGuildExportMeshFetchMixin(
exportMeshFetchRegistry.auditExportArchive
)
const platformAutomationDigestMeshFetchMixin = buildGuildExportMeshFetchMixin(
exportMeshFetchRegistry.automationDigestSnapshot
)
module.exports = {
platformAuditExportMeshFetchMixin,
platformAutomationDigestMeshFetchMixin
}
@@ -1,105 +1,4 @@
'use strict'
const { markRpcResponse } = require('../../../gossip-rpc-validators')
const {
withExportMeshFetchAttempt,
resolveExportMeshFetchWaiterByPrefix,
resolveExportMeshFetchWaiterByExactKey,
buildGuildExportMeshGossipRequestBase
} = require('../../../gossip-rpc-export-mesh')
const isValidAuditExportArchiveMeshRow = (r) => Boolean(r?.entries?.length)
const isValidAutomationDigestSnapshotMeshRow = (r) => Boolean(r?.body?.length)
function formatAutomationDigestSnapshotMeshRow (row, opts) {
return withExportMeshFetchAttempt(opts, {
snapshotId: row.id,
format: row.format,
body: row.body,
summaryLines: row.summaryLines,
exportedAt: row.exportedAt
})
}
/** Registry entries for targeted export mesh fetch mixins (Phase 899). */
const exportMeshFetchRegistry = {
auditExportArchive: {
resolveWaiterMethod: '_resolveAuditArchiveFetchWaiter',
fetchFromMeshMethod: 'fetchAuditExportArchiveFromMesh',
fetchOnceMethod: '_fetchAuditExportArchiveFromMeshOnce',
waitersKey: '_auditArchiveFetchWaiters',
resolveWaiter: resolveExportMeshFetchWaiterByPrefix,
permissionError: 'no permission to fetch audit export archive',
notFoundMessage: 'audit export archive not found on mesh',
validateLocal: isValidAuditExportArchiveMeshRow,
waiterMode: 'append',
timeoutErrorMessage: 'audit archive fetch timed out',
getLocalRow: (platform, archiveId) => platform.deliveryReceipts.getAuditExportArchive(archiveId),
tryRpc: (platform, archiveId, opts) => platform._tryFetchAuditExportArchiveFromMeshRpc(archiveId, opts),
ingestRpc: (platform, rpc) => platform.deliveryReceipts.ingestAuditExportArchive(rpc),
formatLocalHit: async (platform, archiveId, opts) => withExportMeshFetchAttempt(
opts,
await platform.exportAuditExportArchive(archiveId, opts)
),
formatRpcHit: async (platform, archiveId, opts, rpcArch) => markRpcResponse(withExportMeshFetchAttempt(
opts,
await platform.exportAuditExportArchive(rpcArch.id || archiveId, opts)
)),
formatGossipResult: async (platform, archiveId, opts, fetched) => withExportMeshFetchAttempt(
opts,
await platform.exportAuditExportArchive(fetched.id || archiveId, opts)
),
sendGossipRequest: (platform, archiveId, opts, requestId) => {
if (platform.guild.gossipAuditExportArchiveRequest) {
platform.guild.gossipAuditExportArchiveRequest({
...buildGuildExportMeshGossipRequestBase(platform, opts, requestId),
archiveId,
attempt: Number(opts.attempt) || 0
})
}
}
},
automationDigestSnapshot: {
resolveWaiterMethod: '_resolveAutomationDigestSnapshotFetchWaiter',
fetchFromMeshMethod: 'fetchAutomationDigestSnapshotFromMesh',
fetchOnceMethod: '_fetchAutomationDigestSnapshotFromMeshOnce',
waitersKey: '_automationDigestSnapshotFetchWaiters',
resolveWaiter: resolveExportMeshFetchWaiterByExactKey,
permissionError: 'no permission to fetch automation digest snapshot',
notFoundMessage: 'automation digest snapshot not found on mesh',
validateLocal: isValidAutomationDigestSnapshotMeshRow,
waiterMode: 'replace',
timeoutErrorMessage: 'automation digest snapshot fetch timed out',
getLocalRow: (platform, snapshotId) =>
platform.deliveryReceipts.getAutomationDigestExportSnapshot(snapshotId),
tryRpc: (platform, snapshotId, opts) =>
platform._tryFetchAutomationDigestSnapshotFromMeshRpc(snapshotId, opts),
ingestRpc: (platform, rpc) => platform.deliveryReceipts.ingestAutomationDigestExportSnapshot(rpc),
formatLocalHit: (platform, snapshotId, opts, row) =>
formatAutomationDigestSnapshotMeshRow(row, opts),
formatRpcHit: (platform, snapshotId, opts, rpcSnap) => markRpcResponse(formatAutomationDigestSnapshotMeshRow({
id: rpcSnap.id || snapshotId,
format: rpcSnap.format,
body: rpcSnap.body,
summaryLines: rpcSnap.summaryLines,
exportedAt: rpcSnap.exportedAt
}, opts)),
formatGossipResult: (platform, snapshotId, opts, fetched) =>
formatAutomationDigestSnapshotMeshRow(fetched, opts),
sendGossipRequest: (platform, snapshotId, opts, requestId) => {
if (platform.guild.gossipAutomationDigestExportSnapshotRequest) {
platform.guild.gossipAutomationDigestExportSnapshotRequest({
...buildGuildExportMeshGossipRequestBase(platform, opts, requestId),
snapshotId
})
}
}
}
}
module.exports = {
exportMeshFetchRegistry,
isValidAuditExportArchiveMeshRow,
isValidAutomationDigestSnapshotMeshRow,
formatAutomationDigestSnapshotMeshRow
}
/** Re-export from platform-root export mesh registry (Phase 900). */
module.exports = require('../../../gossip-rpc-export-mesh-registry')