Phase 903: export mesh format helper extract + mixin method registry (v0.8.870)

Non-breaking refactor — gossip-rpc-export-mesh-format-audit.js and
gossip-rpc-export-mesh-format-digest.js extract format/send helpers from
registry entries; listExportMeshFetchMixinMethods() and
lookupExportMeshFetchRegistryEntryByMixinMethod() extend registry lookup;
exportMeshFetchMixinMethods on platform RPC view. Default gossip v1 unchanged;
fleet v2 cutover still deferred.

Verification: test:ci-phase903, pear run boot, pearcord.log scan.
This commit is contained in:
Raven Scott
2026-06-04 19:48:44 -04:00
parent a5e6dc7c92
commit 9ded6fc090
8 changed files with 161 additions and 59 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 903 (v0.8.870):** Export mesh format helper extract + mixin method registry. Bundle: `npm run test:ci-phase903`.
**Phase 902 (v0.8.869):** Export mesh view snapshot + mixin pick helper + RPC import consolidation. Bundle: `npm run test:ci-phase902`.
**Phase 901 (v0.8.868):** Export mesh registry entry split + lookup/alignment validation. Bundle: `npm run test:ci-phase901`.
+43
View File
@@ -0,0 +1,43 @@
'use strict'
const { markRpcResponse } = require('./gossip-rpc-validators')
const { withExportMeshFetchAttempt } = require('./gossip-rpc-export-mesh-attempt')
const { buildGuildExportMeshGossipRequestBase } = require('./gossip-rpc-export-mesh-gossip-wait-build')
async function formatAuditExportArchiveMeshLocalHit (platform, archiveId, opts) {
return withExportMeshFetchAttempt(
opts,
await platform.exportAuditExportArchive(archiveId, opts)
)
}
async function formatAuditExportArchiveMeshRpcHit (platform, archiveId, opts, rpcArch) {
return markRpcResponse(withExportMeshFetchAttempt(
opts,
await platform.exportAuditExportArchive(rpcArch.id || archiveId, opts)
))
}
async function formatAuditExportArchiveMeshGossipResult (platform, archiveId, opts, fetched) {
return withExportMeshFetchAttempt(
opts,
await platform.exportAuditExportArchive(fetched.id || archiveId, opts)
)
}
function sendAuditExportArchiveMeshGossipRequest (platform, archiveId, opts, requestId) {
if (platform.guild.gossipAuditExportArchiveRequest) {
platform.guild.gossipAuditExportArchiveRequest({
...buildGuildExportMeshGossipRequestBase(platform, opts, requestId),
archiveId,
attempt: Number(opts.attempt) || 0
})
}
}
module.exports = {
formatAuditExportArchiveMeshLocalHit,
formatAuditExportArchiveMeshRpcHit,
formatAuditExportArchiveMeshGossipResult,
sendAuditExportArchiveMeshGossipRequest
}
+39
View File
@@ -0,0 +1,39 @@
'use strict'
const { markRpcResponse } = require('./gossip-rpc-validators')
const { buildGuildExportMeshGossipRequestBase } = require('./gossip-rpc-export-mesh-gossip-wait-build')
const { formatAutomationDigestSnapshotMeshRow } = require('./gossip-rpc-export-mesh-validators')
function formatAutomationDigestSnapshotMeshLocalHit (platform, snapshotId, opts, row) {
return formatAutomationDigestSnapshotMeshRow(row, opts)
}
function formatAutomationDigestSnapshotMeshRpcHit (platform, snapshotId, opts, rpcSnap) {
return markRpcResponse(formatAutomationDigestSnapshotMeshRow({
id: rpcSnap.id || snapshotId,
format: rpcSnap.format,
body: rpcSnap.body,
summaryLines: rpcSnap.summaryLines,
exportedAt: rpcSnap.exportedAt
}, opts))
}
function formatAutomationDigestSnapshotMeshGossipResult (platform, snapshotId, opts, fetched) {
return formatAutomationDigestSnapshotMeshRow(fetched, opts)
}
function sendAutomationDigestSnapshotMeshGossipRequest (platform, snapshotId, opts, requestId) {
if (platform.guild.gossipAutomationDigestExportSnapshotRequest) {
platform.guild.gossipAutomationDigestExportSnapshotRequest({
...buildGuildExportMeshGossipRequestBase(platform, opts, requestId),
snapshotId
})
}
}
module.exports = {
formatAutomationDigestSnapshotMeshLocalHit,
formatAutomationDigestSnapshotMeshRpcHit,
formatAutomationDigestSnapshotMeshGossipResult,
sendAutomationDigestSnapshotMeshGossipRequest
}
+11 -25
View File
@@ -1,12 +1,15 @@
'use strict'
const { markRpcResponse } = require('./gossip-rpc-validators')
const { withExportMeshFetchAttempt } = require('./gossip-rpc-export-mesh-attempt')
const { resolveExportMeshFetchWaiterByPrefix } = require('./gossip-rpc-export-mesh-waiter-resolve')
const { buildGuildExportMeshGossipRequestBase } = require('./gossip-rpc-export-mesh-gossip-wait-build')
const { isValidAuditExportArchiveMeshRow } = require('./gossip-rpc-export-mesh-validators')
const {
formatAuditExportArchiveMeshLocalHit,
formatAuditExportArchiveMeshRpcHit,
formatAuditExportArchiveMeshGossipResult,
sendAuditExportArchiveMeshGossipRequest
} = require('./gossip-rpc-export-mesh-format-audit')
/** Audit export archive mesh fetch registry entry (Phase 901). */
/** Audit export archive mesh fetch registry entry (Phase 901903). */
const auditExportArchiveMeshFetchEntry = {
pullConfigKey: 'auditExportArchive',
resolveWaiterMethod: '_resolveAuditArchiveFetchWaiter',
@@ -22,27 +25,10 @@ const auditExportArchiveMeshFetchEntry = {
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
})
}
}
formatLocalHit: formatAuditExportArchiveMeshLocalHit,
formatRpcHit: formatAuditExportArchiveMeshRpcHit,
formatGossipResult: formatAuditExportArchiveMeshGossipResult,
sendGossipRequest: sendAuditExportArchiveMeshGossipRequest
}
module.exports = { auditExportArchiveMeshFetchEntry }
+11 -25
View File
@@ -1,14 +1,15 @@
'use strict'
const { markRpcResponse } = require('./gossip-rpc-validators')
const { resolveExportMeshFetchWaiterByExactKey } = require('./gossip-rpc-export-mesh-waiter-resolve')
const { buildGuildExportMeshGossipRequestBase } = require('./gossip-rpc-export-mesh-gossip-wait-build')
const { isValidAutomationDigestSnapshotMeshRow } = require('./gossip-rpc-export-mesh-validators')
const {
isValidAutomationDigestSnapshotMeshRow,
formatAutomationDigestSnapshotMeshRow
} = require('./gossip-rpc-export-mesh-validators')
formatAutomationDigestSnapshotMeshLocalHit,
formatAutomationDigestSnapshotMeshRpcHit,
formatAutomationDigestSnapshotMeshGossipResult,
sendAutomationDigestSnapshotMeshGossipRequest
} = require('./gossip-rpc-export-mesh-format-digest')
/** Automation digest snapshot mesh fetch registry entry (Phase 901). */
/** Automation digest snapshot mesh fetch registry entry (Phase 901903). */
const automationDigestSnapshotMeshFetchEntry = {
pullConfigKey: 'automationDigestSnapshot',
resolveWaiterMethod: '_resolveAutomationDigestSnapshotFetchWaiter',
@@ -26,25 +27,10 @@ const automationDigestSnapshotMeshFetchEntry = {
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
})
}
}
formatLocalHit: formatAutomationDigestSnapshotMeshLocalHit,
formatRpcHit: formatAutomationDigestSnapshotMeshRpcHit,
formatGossipResult: formatAutomationDigestSnapshotMeshGossipResult,
sendGossipRequest: sendAutomationDigestSnapshotMeshGossipRequest
}
module.exports = { automationDigestSnapshotMeshFetchEntry }
+27 -1
View File
@@ -6,6 +6,19 @@ function listExportMeshFetchRegistryKeys () {
return Object.keys(exportMeshFetchRegistry)
}
function listExportMeshFetchMixinMethods () {
const methods = []
for (const name of listExportMeshFetchRegistryKeys()) {
const entry = exportMeshFetchRegistry[name]
methods.push(
entry.resolveWaiterMethod,
entry.fetchFromMeshMethod,
entry.fetchOnceMethod
)
}
return methods
}
function lookupExportMeshFetchRegistryEntry (name) {
const entry = exportMeshFetchRegistry[name]
if (!entry) return null
@@ -19,6 +32,16 @@ function lookupExportMeshFetchRegistryEntryByPullConfig (pullConfigKey) {
return name ? lookupExportMeshFetchRegistryEntry(name) : null
}
function lookupExportMeshFetchRegistryEntryByMixinMethod (methodName) {
const name = listExportMeshFetchRegistryKeys().find((key) => {
const entry = exportMeshFetchRegistry[key]
return entry.resolveWaiterMethod === methodName ||
entry.fetchFromMeshMethod === methodName ||
entry.fetchOnceMethod === methodName
})
return name ? lookupExportMeshFetchRegistryEntry(name) : null
}
function buildExportMeshFetchRegistrySnapshot () {
return listExportMeshFetchRegistryKeys().map((name) => {
const entry = exportMeshFetchRegistry[name]
@@ -36,14 +59,17 @@ function buildExportMeshFetchRegistrySnapshot () {
function buildExportMeshFetchRegistryDiagnosticsSnapshot () {
return {
exportMeshFetchRegistryKeys: listExportMeshFetchRegistryKeys(),
exportMeshFetchRegistrySnapshot: buildExportMeshFetchRegistrySnapshot()
exportMeshFetchRegistrySnapshot: buildExportMeshFetchRegistrySnapshot(),
exportMeshFetchMixinMethods: listExportMeshFetchMixinMethods()
}
}
module.exports = {
listExportMeshFetchRegistryKeys,
listExportMeshFetchMixinMethods,
lookupExportMeshFetchRegistryEntry,
lookupExportMeshFetchRegistryEntryByPullConfig,
lookupExportMeshFetchRegistryEntryByMixinMethod,
buildExportMeshFetchRegistrySnapshot,
buildExportMeshFetchRegistryDiagnosticsSnapshot
}
+23 -7
View File
@@ -2,15 +2,27 @@
const { gossipRpcPullConfigs } = require('./gossip-rpc-pull-config')
const { exportMeshFetchRegistry } = require('./gossip-rpc-export-mesh-registry')
const { listExportMeshFetchRegistryKeys } = require('./gossip-rpc-export-mesh-registry-lookup')
const {
listExportMeshFetchRegistryKeys,
listExportMeshFetchMixinMethods
} = require('./gossip-rpc-export-mesh-registry-lookup')
const exportMeshPullConfigKeys = ['auditExportArchive', 'automationDigestSnapshot']
/** Validate export mesh fetch registry alignment with gossip RPC pull configs (Phase 901). */
function assertUniqueExportMeshMethod (methodSet, methodName, label) {
if (methodSet.has(methodName)) {
throw new Error(`duplicate export mesh ${label}: ${methodName}`)
}
methodSet.add(methodName)
}
/** Validate export mesh fetch registry alignment with gossip RPC pull configs (Phase 901903). */
function validateExportMeshFetchRegistryAlignment () {
const keys = listExportMeshFetchRegistryKeys()
const pullConfigKeys = Object.keys(gossipRpcPullConfigs)
const methodSet = new Set()
const fetchFromMeshMethods = new Set()
const resolveWaiterMethods = new Set()
const fetchOnceMethods = new Set()
for (const name of keys) {
const entry = exportMeshFetchRegistry[name]
@@ -30,10 +42,9 @@ function validateExportMeshFetchRegistryAlignment () {
throw new Error(`export mesh registry entry missing ${methodKey}: ${name}`)
}
}
if (methodSet.has(entry.fetchFromMeshMethod)) {
throw new Error(`duplicate export mesh fetchFromMeshMethod: ${entry.fetchFromMeshMethod}`)
}
methodSet.add(entry.fetchFromMeshMethod)
assertUniqueExportMeshMethod(fetchFromMeshMethods, entry.fetchFromMeshMethod, 'fetchFromMeshMethod')
assertUniqueExportMeshMethod(resolveWaiterMethods, entry.resolveWaiterMethod, 'resolveWaiterMethod')
assertUniqueExportMeshMethod(fetchOnceMethods, entry.fetchOnceMethod, 'fetchOnceMethod')
}
for (const pullConfigKey of exportMeshPullConfigKeys) {
@@ -42,6 +53,11 @@ function validateExportMeshFetchRegistryAlignment () {
}
}
const mixinMethods = listExportMeshFetchMixinMethods()
if (mixinMethods.length !== keys.length * 3) {
throw new Error(`export mesh mixin method count ${mixinMethods.length}`)
}
return true
}
+5 -1
View File
@@ -12,6 +12,8 @@ const meshValidators = require('./gossip-rpc-export-mesh-validators')
const meshRegistry = require('./gossip-rpc-export-mesh-registry')
const meshRegistryLookup = require('./gossip-rpc-export-mesh-registry-lookup')
const meshRegistryValidate = require('./gossip-rpc-export-mesh-registry-validate')
const meshFormatAudit = require('./gossip-rpc-export-mesh-format-audit')
const meshFormatDigest = require('./gossip-rpc-export-mesh-format-digest')
module.exports = {
...attempt,
@@ -24,5 +26,7 @@ module.exports = {
...meshValidators,
...meshRegistry,
...meshRegistryLookup,
...meshRegistryValidate
...meshRegistryValidate,
...meshFormatAudit,
...meshFormatDigest
}