Phase 899: export mesh fetch registry + bind helper extract (v0.8.866)
Non-breaking refactor — platform-export-mesh-fetch-registry.js and buildGuildExportMeshFetchMixin() registry-bind audit/digest mesh fetch mixins into thin config-driven wrappers. Default gossip v1 unchanged; fleet v2 cutover still deferred. Verification: test:ci-phase899, pear run boot, pearcord.log scan.
This commit is contained in:
@@ -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 822 (v0.8.789):** Triple-peer topology via `guild-mesh-topology` + `getMeshStabilityStats`. Bundle: `npm run test:ci-phase822`.
|
||||||
|
|
||||||
|
**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`.
|
**Phase 898 (v0.8.865):** Export mesh barrel + attempt/waiter/gossip-wait-build extract. Bundle: `npm run test:ci-phase898`.
|
||||||
|
|
||||||
**Phase 897 (v0.8.864):** Export mesh fetch-once orchestrator extract. Bundle: `npm run test:ci-phase897`.
|
**Phase 897 (v0.8.864):** Export mesh fetch-once orchestrator extract. Bundle: `npm run test:ci-phase897`.
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const {
|
||||||
|
buildGuildExportMeshGossipWaitCallback,
|
||||||
|
buildGuildExportMeshGossipRequestBase
|
||||||
|
} = require('./gossip-rpc-export-mesh-gossip-wait-build')
|
||||||
|
const { fetchGuildExportMeshFromMesh, fetchGuildExportMeshResourceOnce } = require('./gossip-rpc-export-mesh-fetch-once')
|
||||||
|
|
||||||
|
/** Build platform mesh fetch mixin methods from a registry entry (Phase 899). */
|
||||||
|
function buildGuildExportMeshFetchMixin (entry) {
|
||||||
|
return {
|
||||||
|
[entry.resolveWaiterMethod] (resource) {
|
||||||
|
entry.resolveWaiter(this[entry.waitersKey], resource, entry.validateLocal)
|
||||||
|
},
|
||||||
|
|
||||||
|
async [entry.fetchFromMeshMethod] (resourceId, opts = {}) {
|
||||||
|
return fetchGuildExportMeshFromMesh(this, {
|
||||||
|
resourceId,
|
||||||
|
opts,
|
||||||
|
permissionError: entry.permissionError,
|
||||||
|
notFoundMessage: entry.notFoundMessage,
|
||||||
|
fetchOnce: (id, o) => this[entry.fetchOnceMethod](id, o)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
async [entry.fetchOnceMethod] (resourceId, opts = {}) {
|
||||||
|
const platform = this
|
||||||
|
return fetchGuildExportMeshResourceOnce(platform, {
|
||||||
|
opts,
|
||||||
|
getLocalRow: () => entry.getLocalRow(platform, resourceId),
|
||||||
|
validateLocal: entry.validateLocal,
|
||||||
|
formatLocalHit: (row) => entry.formatLocalHit(platform, resourceId, opts, row),
|
||||||
|
tryRpc: () => entry.tryRpc(platform, resourceId, opts),
|
||||||
|
ingestRpc: (rpc) => entry.ingestRpc(platform, rpc),
|
||||||
|
formatRpcHit: (rpc) => entry.formatRpcHit(platform, resourceId, opts, rpc),
|
||||||
|
meshGossipWait: buildGuildExportMeshGossipWaitCallback({
|
||||||
|
resourceId,
|
||||||
|
opts,
|
||||||
|
waiters: platform[entry.waitersKey],
|
||||||
|
waiterMode: entry.waiterMode,
|
||||||
|
timeoutErrorMessage: entry.timeoutErrorMessage,
|
||||||
|
notFoundMessage: entry.notFoundMessage,
|
||||||
|
sendGossipRequest: (requestId) => entry.sendGossipRequest(platform, resourceId, opts, requestId),
|
||||||
|
refetchLocal: () => entry.getLocalRow(platform, resourceId),
|
||||||
|
validateLocal: entry.validateLocal,
|
||||||
|
formatResult: (fetched) => entry.formatGossipResult(platform, resourceId, opts, fetched)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
buildGuildExportMeshFetchMixin,
|
||||||
|
buildGuildExportMeshGossipRequestBase,
|
||||||
|
buildGuildExportMeshGossipWaitCallback
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ const gossipWait = require('./gossip-rpc-export-mesh-gossip-wait')
|
|||||||
const gossipWaitBuild = require('./gossip-rpc-export-mesh-gossip-wait-build')
|
const gossipWaitBuild = require('./gossip-rpc-export-mesh-gossip-wait-build')
|
||||||
const fetchOnce = require('./gossip-rpc-export-mesh-fetch-once')
|
const fetchOnce = require('./gossip-rpc-export-mesh-fetch-once')
|
||||||
const waiterResolve = require('./gossip-rpc-export-mesh-waiter-resolve')
|
const waiterResolve = require('./gossip-rpc-export-mesh-waiter-resolve')
|
||||||
|
const meshBind = require('./gossip-rpc-export-mesh-bind')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
...attempt,
|
...attempt,
|
||||||
@@ -14,5 +15,6 @@ module.exports = {
|
|||||||
...gossipWait,
|
...gossipWait,
|
||||||
...gossipWaitBuild,
|
...gossipWaitBuild,
|
||||||
...fetchOnce,
|
...fetchOnce,
|
||||||
...waiterResolve
|
...waiterResolve,
|
||||||
|
...meshBind
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,77 +1,11 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const {
|
const { buildGuildExportMeshFetchMixin } = require('../../../gossip-rpc-export-mesh-bind')
|
||||||
markRpcResponse,
|
const { exportMeshFetchRegistry } = require('./platform-export-mesh-fetch-registry')
|
||||||
withExportMeshFetchAttempt,
|
|
||||||
resolveExportMeshFetchWaiterByPrefix,
|
|
||||||
buildGuildExportMeshGossipRequestBase,
|
|
||||||
buildGuildExportMeshGossipWaitCallback,
|
|
||||||
fetchGuildExportMeshFromMesh,
|
|
||||||
fetchGuildExportMeshResourceOnce
|
|
||||||
} = require('../../../gossip-rpc-pull')
|
|
||||||
|
|
||||||
const validateAuditArchive = (r) => Boolean(r?.entries?.length)
|
/** Audit export archive mesh fetch + gossip waiters (Phase 895–899). */
|
||||||
|
const platformAuditExportMeshFetchMixin = buildGuildExportMeshFetchMixin(
|
||||||
/** Audit export archive mesh fetch + gossip waiters (Phase 895–898). */
|
exportMeshFetchRegistry.auditExportArchive
|
||||||
const platformAuditExportMeshFetchMixin = {
|
)
|
||||||
_resolveAuditArchiveFetchWaiter (archive) {
|
|
||||||
resolveExportMeshFetchWaiterByPrefix(
|
|
||||||
this._auditArchiveFetchWaiters,
|
|
||||||
archive,
|
|
||||||
validateAuditArchive
|
|
||||||
)
|
|
||||||
},
|
|
||||||
|
|
||||||
async fetchAuditExportArchiveFromMesh (archiveId, opts = {}) {
|
|
||||||
return fetchGuildExportMeshFromMesh(this, {
|
|
||||||
resourceId: archiveId,
|
|
||||||
opts,
|
|
||||||
permissionError: 'no permission to fetch audit export archive',
|
|
||||||
notFoundMessage: 'audit export archive not found on mesh',
|
|
||||||
fetchOnce: (id, o) => this._fetchAuditExportArchiveFromMeshOnce(id, o)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
async _fetchAuditExportArchiveFromMeshOnce (archiveId, opts = {}) {
|
|
||||||
return fetchGuildExportMeshResourceOnce(this, {
|
|
||||||
opts,
|
|
||||||
getLocalRow: () => this.deliveryReceipts.getAuditExportArchive(archiveId),
|
|
||||||
validateLocal: validateAuditArchive,
|
|
||||||
formatLocalHit: async () => withExportMeshFetchAttempt(
|
|
||||||
opts,
|
|
||||||
await this.exportAuditExportArchive(archiveId, opts)
|
|
||||||
),
|
|
||||||
tryRpc: () => this._tryFetchAuditExportArchiveFromMeshRpc(archiveId, opts),
|
|
||||||
ingestRpc: (rpc) => this.deliveryReceipts.ingestAuditExportArchive(rpc),
|
|
||||||
formatRpcHit: async (rpcArch) => markRpcResponse(withExportMeshFetchAttempt(
|
|
||||||
opts,
|
|
||||||
await this.exportAuditExportArchive(rpcArch.id || archiveId, opts)
|
|
||||||
)),
|
|
||||||
meshGossipWait: buildGuildExportMeshGossipWaitCallback({
|
|
||||||
resourceId: archiveId,
|
|
||||||
opts,
|
|
||||||
waiters: this._auditArchiveFetchWaiters,
|
|
||||||
waiterMode: 'append',
|
|
||||||
timeoutErrorMessage: 'audit archive fetch timed out',
|
|
||||||
notFoundMessage: 'audit export archive not found on mesh',
|
|
||||||
sendGossipRequest: (requestId) => {
|
|
||||||
if (this.guild.gossipAuditExportArchiveRequest) {
|
|
||||||
this.guild.gossipAuditExportArchiveRequest({
|
|
||||||
...buildGuildExportMeshGossipRequestBase(this, opts, requestId),
|
|
||||||
archiveId,
|
|
||||||
attempt: Number(opts.attempt) || 0
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
refetchLocal: () => this.deliveryReceipts.getAuditExportArchive(archiveId),
|
|
||||||
validateLocal: validateAuditArchive,
|
|
||||||
formatResult: async (fetched) => withExportMeshFetchAttempt(
|
|
||||||
opts,
|
|
||||||
await this.exportAuditExportArchive(fetched.id || archiveId, opts)
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { platformAuditExportMeshFetchMixin }
|
module.exports = { platformAuditExportMeshFetchMixin }
|
||||||
|
|||||||
@@ -1,83 +1,11 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const {
|
const { buildGuildExportMeshFetchMixin } = require('../../../gossip-rpc-export-mesh-bind')
|
||||||
markRpcResponse,
|
const { exportMeshFetchRegistry } = require('./platform-export-mesh-fetch-registry')
|
||||||
withExportMeshFetchAttempt,
|
|
||||||
resolveExportMeshFetchWaiterByExactKey,
|
|
||||||
buildGuildExportMeshGossipRequestBase,
|
|
||||||
buildGuildExportMeshGossipWaitCallback,
|
|
||||||
fetchGuildExportMeshFromMesh,
|
|
||||||
fetchGuildExportMeshResourceOnce
|
|
||||||
} = require('../../../gossip-rpc-pull')
|
|
||||||
|
|
||||||
const validateDigestSnapshot = (r) => Boolean(r?.body?.length)
|
/** Automation digest snapshot mesh fetch + gossip waiters (Phase 895–899). */
|
||||||
|
const platformAutomationDigestMeshFetchMixin = buildGuildExportMeshFetchMixin(
|
||||||
function formatDigestSnapshotRow (row, opts) {
|
exportMeshFetchRegistry.automationDigestSnapshot
|
||||||
return withExportMeshFetchAttempt(opts, {
|
)
|
||||||
snapshotId: row.id,
|
|
||||||
format: row.format,
|
|
||||||
body: row.body,
|
|
||||||
summaryLines: row.summaryLines,
|
|
||||||
exportedAt: row.exportedAt
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Automation digest snapshot mesh fetch + gossip waiters (Phase 895–898). */
|
|
||||||
const platformAutomationDigestMeshFetchMixin = {
|
|
||||||
_resolveAutomationDigestSnapshotFetchWaiter (snap) {
|
|
||||||
resolveExportMeshFetchWaiterByExactKey(
|
|
||||||
this._automationDigestSnapshotFetchWaiters,
|
|
||||||
snap,
|
|
||||||
validateDigestSnapshot
|
|
||||||
)
|
|
||||||
},
|
|
||||||
|
|
||||||
async fetchAutomationDigestSnapshotFromMesh (snapshotId, opts = {}) {
|
|
||||||
return fetchGuildExportMeshFromMesh(this, {
|
|
||||||
resourceId: snapshotId,
|
|
||||||
opts,
|
|
||||||
permissionError: 'no permission to fetch automation digest snapshot',
|
|
||||||
notFoundMessage: 'automation digest snapshot not found on mesh',
|
|
||||||
fetchOnce: (id, o) => this._fetchAutomationDigestSnapshotFromMeshOnce(id, o)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
async _fetchAutomationDigestSnapshotFromMeshOnce (snapshotId, opts = {}) {
|
|
||||||
return fetchGuildExportMeshResourceOnce(this, {
|
|
||||||
opts,
|
|
||||||
getLocalRow: () => this.deliveryReceipts.getAutomationDigestExportSnapshot(snapshotId),
|
|
||||||
validateLocal: validateDigestSnapshot,
|
|
||||||
formatLocalHit: (row) => formatDigestSnapshotRow(row, opts),
|
|
||||||
tryRpc: () => this._tryFetchAutomationDigestSnapshotFromMeshRpc(snapshotId, opts),
|
|
||||||
ingestRpc: (rpc) => this.deliveryReceipts.ingestAutomationDigestExportSnapshot(rpc),
|
|
||||||
formatRpcHit: (rpcSnap) => markRpcResponse(formatDigestSnapshotRow({
|
|
||||||
id: rpcSnap.id || snapshotId,
|
|
||||||
format: rpcSnap.format,
|
|
||||||
body: rpcSnap.body,
|
|
||||||
summaryLines: rpcSnap.summaryLines,
|
|
||||||
exportedAt: rpcSnap.exportedAt
|
|
||||||
}, opts)),
|
|
||||||
meshGossipWait: buildGuildExportMeshGossipWaitCallback({
|
|
||||||
resourceId: snapshotId,
|
|
||||||
opts,
|
|
||||||
waiters: this._automationDigestSnapshotFetchWaiters,
|
|
||||||
waiterMode: 'replace',
|
|
||||||
timeoutErrorMessage: 'automation digest snapshot fetch timed out',
|
|
||||||
notFoundMessage: 'automation digest snapshot not found on mesh',
|
|
||||||
sendGossipRequest: (requestId) => {
|
|
||||||
if (this.guild.gossipAutomationDigestExportSnapshotRequest) {
|
|
||||||
this.guild.gossipAutomationDigestExportSnapshotRequest({
|
|
||||||
...buildGuildExportMeshGossipRequestBase(this, opts, requestId),
|
|
||||||
snapshotId
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
refetchLocal: () => this.deliveryReceipts.getAutomationDigestExportSnapshot(snapshotId),
|
|
||||||
validateLocal: validateDigestSnapshot,
|
|
||||||
formatResult: (fetched) => formatDigestSnapshotRow(fetched, opts)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { platformAutomationDigestMeshFetchMixin }
|
module.exports = { platformAutomationDigestMeshFetchMixin }
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
'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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user