feat(platform): Phase 724 worker-release.json and integration-manifest.json mesh (v0.8.700)

Add dedicated mixins, integration manifest read/clear APIs, partition heal
cursors, view meta/counts, and span renames for worker export JSON parity.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-06-03 09:06:18 -04:00
co-authored by Cursor
parent c861e51cf3
commit 48ab2c64e5
4 changed files with 223 additions and 20 deletions
+2
View File
@@ -54,6 +54,8 @@ Application facade: one `PearcordPlatform` class that wires identity, database,
**Phase 723 (v0.8.699):** Dedicated slash registry & invoke audit export JSON — `slash-registry-json-mixin.js`, `slash-invoke-audit-json-mixin.js`, spans `slash-registry.json` / `slash-invoke-audit.json`, `getSlashInvokeAuditExportJsonExport`, `clearSlashInvokeAuditExportJsonExports`, deep links `openSlashRegistryJson` / `openSlashInvokeAuditJson`. Bundle: `npm run test:ci-phase723`. **Phase 723 (v0.8.699):** Dedicated slash registry & invoke audit export JSON — `slash-registry-json-mixin.js`, `slash-invoke-audit-json-mixin.js`, spans `slash-registry.json` / `slash-invoke-audit.json`, `getSlashInvokeAuditExportJsonExport`, `clearSlashInvokeAuditExportJsonExports`, deep links `openSlashRegistryJson` / `openSlashInvokeAuditJson`. Bundle: `npm run test:ci-phase723`.
**Phase 724 (v0.8.700):** Dedicated worker release & integration manifest export JSON — `worker-release-json-mixin.js`, `integration-manifest-json-mixin.js`, spans `worker-release.json` / `integration-manifest.json`, `getIntegrationManifestExportJsonExport`, `clearIntegrationManifestExportJsonExports`, deep links `openWorkerReleaseJson` / `openIntegrationManifestJson`. Bundle: `npm run test:ci-phase724`.
**Phase 695 (v0.8.670):** Slash registry JSON & invoke audit — `slash-json-mixin.js`, `slash.json` spans (`guildSlashRegistryCount`), `pushSlashRegistryJsonToMesh`, `pushSlashInvokeAuditExportToMesh`, deep link `openSlashJson`. Bundle: `npm run test:ci-phase695`. **Phase 695 (v0.8.670):** Slash registry JSON & invoke audit — `slash-json-mixin.js`, `slash.json` spans (`guildSlashRegistryCount`), `pushSlashRegistryJsonToMesh`, `pushSlashInvokeAuditExportToMesh`, deep link `openSlashJson`. Bundle: `npm run test:ci-phase695`.
**Phase 692 (v0.8.667):** Digest relay handoff JSON & archive export — `relay-json-mixin.js`, `relay.json` spans, `pushDigestRelayHandoffJsonToMesh`, `pushArchivePeerExportToMesh`, deep link `openRelayJson`. Bundle: `npm run test:ci-phase692`. **Phase 692 (v0.8.667):** Digest relay handoff JSON & archive export — `relay-json-mixin.js`, `relay.json` spans, `pushDigestRelayHandoffJsonToMesh`, `pushArchivePeerExportToMesh`, deep link `openRelayJson`. Bundle: `npm run test:ci-phase692`.
+90 -20
View File
@@ -1791,10 +1791,10 @@ class PearcordPlatform extends EventEmitter {
const archivePeerExportHeal = await this._healArchivePeerExportCursorOnPartition(gid).catch(() => ({ const archivePeerExportHeal = await this._healArchivePeerExportCursorOnPartition(gid).catch(() => ({
relisted: 0 relisted: 0
})) }))
const workerReleaseJsonHeal = await this._healWorkerReleaseExportCursorOnPartition(gid).catch(() => ({ const workerReleaseJsonHeal = await this._healWorkerReleaseJsonExportCursorOnPartition(gid).catch(() => ({
relisted: 0 relisted: 0
})) }))
const integrationManifestHeal = await this._healIntegrationManifestCursorOnPartition(gid).catch(() => ({ const integrationManifestJsonHeal = await this._healIntegrationManifestJsonExportCursorOnPartition(gid).catch(() => ({
relisted: 0 relisted: 0
})) }))
const botRegistryJsonHeal = await this._healBotRegistryExportCursorOnPartition(gid).catch(() => ({ const botRegistryJsonHeal = await this._healBotRegistryExportCursorOnPartition(gid).catch(() => ({
@@ -1927,7 +1927,7 @@ class PearcordPlatform extends EventEmitter {
digestRelayHandoffJsonHeal, digestRelayHandoffJsonHeal,
archivePeerExportHeal, archivePeerExportHeal,
workerReleaseJsonHeal, workerReleaseJsonHeal,
integrationManifestHeal, integrationManifestJsonHeal,
botRegistryJsonHeal, botRegistryJsonHeal,
webhookExecuteJsonHeal, webhookExecuteJsonHeal,
slashRegistryJsonHeal, slashRegistryJsonHeal,
@@ -13836,8 +13836,8 @@ class PearcordPlatform extends EventEmitter {
async getWorkerReleaseJsonExport () { async getWorkerReleaseJsonExport () {
const gid = this.guild?.guild?.id || null const gid = this.guild?.guild?.id || null
const span = this.log.time('worker.json', { const span = this.log.time('worker-release.json', {
spanKind: 'worker.json', spanKind: 'worker-release.json',
guildId: gid, guildId: gid,
context: 'read' context: 'read'
}) })
@@ -13849,23 +13849,23 @@ class PearcordPlatform extends EventEmitter {
await this._initDeliveryReceipts(this.guild.guild.id) await this._initDeliveryReceipts(this.guild.guild.id)
const row = await this.deliveryReceipts.getWorkerReleaseJsonExport() const row = await this.deliveryReceipts.getWorkerReleaseJsonExport()
if (!row?.signature) { if (!row?.signature) {
span.end({ guildWorkerReleaseCount: row ? 1 : 0, hasSignature: false, bridgeKind: 'worker.json' }) span.end({ guildWorkerReleaseJsonCount: row ? 1 : 0, hasSignature: false, bridgeKind: 'worker-release.json' })
return row return row
} }
const verified = verifyWorkerReleaseJson(exportBodyFromSlice(row) || row.jsonBody || row.jsonBody, row.signature, { const verified = verifyWorkerReleaseJson(exportBodyFromSlice(row) || row.jsonBody || row.jsonBody, row.signature, {
guildId: this.guild.guild.id, guildId: this.guild.guild.id,
relaySecret: this.guild.guild.id relaySecret: this.guild.guild.id
}) })
const out = { ...row, signatureValid: verified.ok } const out = { ...row, signatureValid: verified.ok, releaseCount: row.releaseCount || 0 }
span.end({ span.end({
guildWorkerReleaseCount: 1, guildWorkerReleaseJsonCount: 1,
hasSignature: true, hasSignature: true,
signatureValid: verified.ok, signatureValid: verified.ok,
bridgeKind: 'worker.json' bridgeKind: 'worker-release.json'
}) })
return out return out
} catch (err) { } catch (err) {
this.log.error('worker.json error', { this.log.error('worker-release.json error', {
guildId: gid, guildId: gid,
context: 'read', context: 'read',
error: err?.message || String(err) error: err?.message || String(err)
@@ -13913,8 +13913,8 @@ class PearcordPlatform extends EventEmitter {
async pushWorkerReleaseJsonToMesh () { async pushWorkerReleaseJsonToMesh () {
const gid = this.guild?.guild?.id || null const gid = this.guild?.guild?.id || null
const span = this.log.time('worker.json', { const span = this.log.time('worker-release.json', {
spanKind: 'worker.json', spanKind: 'worker-release.json',
guildId: gid, guildId: gid,
context: 'mesh.push' context: 'mesh.push'
}) })
@@ -13945,13 +13945,13 @@ class PearcordPlatform extends EventEmitter {
exportedAt: exported.exportedAt exportedAt: exported.exportedAt
}) })
span.end({ span.end({
guildWorkerReleaseCount: exported.releaseCount || 1, guildWorkerReleaseJsonCount: exported.releaseCount || 1,
meshPushed: true, meshPushed: true,
bridgeKind: 'worker.json' bridgeKind: 'worker-release.json'
}) })
return exported return exported
} catch (err) { } catch (err) {
this.log.error('worker.json error', { this.log.error('worker-release.json error', {
guildId: gid, guildId: gid,
context: 'mesh.push', context: 'mesh.push',
error: err?.message || String(err) error: err?.message || String(err)
@@ -14035,10 +14035,68 @@ class PearcordPlatform extends EventEmitter {
} }
} }
async getIntegrationManifestExportJsonExport () {
const gid = this.guild?.guild?.id || null
const span = this.log.time('integration-manifest.json', {
spanKind: 'integration-manifest.json',
guildId: gid,
context: 'read'
})
try {
if (!this.guild?.guild) {
span.end({ guildIntegrationManifestJsonCount: 0, skipped: true })
return null
}
await this._initDeliveryReceipts(this.guild.guild.id)
const row = await this.deliveryReceipts.getIntegrationManifestExportJsonExport()
if (!row?.signature) {
span.end({
guildIntegrationManifestJsonCount: row ? 1 : 0,
hasSignature: false,
bridgeKind: 'integration-manifest.json'
})
return row
}
const verified = verifyIntegrationManifestExportJson(
exportBodyFromSlice(row) || row.jsonBody || row.jsonBody,
row.signature,
{ guildId: this.guild.guild.id, relaySecret: this.guild.guild.id }
)
const out = { ...row, signatureValid: verified.ok, templateCount: row.templateCount || 0 }
span.end({
guildIntegrationManifestJsonCount: 1,
hasSignature: true,
signatureValid: verified.ok,
bridgeKind: 'integration-manifest.json'
})
return out
} catch (err) {
this.log.error('integration-manifest.json error', {
guildId: gid,
context: 'read',
error: err?.message || String(err)
})
span.fail(err)
throw err
}
}
async clearIntegrationManifestExportJsonExports () {
if (!this.guild?.guild) throw new Error('no guild')
const roles = await this._memberRoles()
if (!roleHasPermission(roles, PERMISSION.MANAGE_GUILD)) {
throw new Error('no permission to clear integration manifest JSON exports')
}
await this._initDeliveryReceipts(this.guild.guild.id)
const removed = await this.deliveryReceipts.clearIntegrationManifestExportJsonExports()
this.emit('integration-manifest-export-json-cleared', { removed })
return { removed }
}
async pushIntegrationManifestExportToMesh () { async pushIntegrationManifestExportToMesh () {
const gid = this.guild?.guild?.id || null const gid = this.guild?.guild?.id || null
const span = this.log.time('worker.json', { const span = this.log.time('integration-manifest.json', {
spanKind: 'worker.json', spanKind: 'integration-manifest.json',
guildId: gid, guildId: gid,
context: 'mesh.manifest' context: 'mesh.manifest'
}) })
@@ -14070,13 +14128,13 @@ class PearcordPlatform extends EventEmitter {
meshPushed: true meshPushed: true
} }
span.end({ span.end({
guildWorkerReleaseCount: exported.templateCount || 0, guildIntegrationManifestJsonCount: exported.templateCount || 0,
meshPushed: true, meshPushed: true,
bridgeKind: 'worker.json' bridgeKind: 'integration-manifest.json'
}) })
return exported return exported
} catch (err) { } catch (err) {
this.log.error('worker.json error', { this.log.error('integration-manifest.json error', {
guildId: gid, guildId: gid,
context: 'mesh.manifest', context: 'mesh.manifest',
error: err?.message || String(err) error: err?.message || String(err)
@@ -18785,6 +18843,8 @@ class PearcordPlatform extends EventEmitter {
openOAuthInstallTokenJson: !!parsed.openOAuthInstallTokenJson, openOAuthInstallTokenJson: !!parsed.openOAuthInstallTokenJson,
openSlashRegistryJson: !!parsed.openSlashRegistryJson, openSlashRegistryJson: !!parsed.openSlashRegistryJson,
openSlashInvokeAuditJson: !!parsed.openSlashInvokeAuditJson, openSlashInvokeAuditJson: !!parsed.openSlashInvokeAuditJson,
openWorkerReleaseJson: !!parsed.openWorkerReleaseJson,
openIntegrationManifestJson: !!parsed.openIntegrationManifestJson,
openChannelFollowJson: !!parsed.openChannelFollowJson, openChannelFollowJson: !!parsed.openChannelFollowJson,
openGuildWidgetJson: !!parsed.openGuildWidgetJson openGuildWidgetJson: !!parsed.openGuildWidgetJson
} }
@@ -32799,6 +32859,7 @@ class PearcordPlatform extends EventEmitter {
let archivePeerExportJsonRows = [] let archivePeerExportJsonRows = []
let workerReleaseJsonMeta = null let workerReleaseJsonMeta = null
let workerReleaseJsonRows = [] let workerReleaseJsonRows = []
let integrationManifestExportJsonMeta = null
let integrationManifestExportJsonRows = [] let integrationManifestExportJsonRows = []
let lastIntegrationManifestExport = null let lastIntegrationManifestExport = null
let botRegistryJsonMeta = null let botRegistryJsonMeta = null
@@ -33003,6 +33064,8 @@ class PearcordPlatform extends EventEmitter {
return { ...row, signatureValid: verified.ok } return { ...row, signatureValid: verified.ok }
}) })
lastIntegrationManifestExport = await this.getLastIntegrationManifestExport() lastIntegrationManifestExport = await this.getLastIntegrationManifestExport()
integrationManifestExportJsonMeta =
await this.getIntegrationManifestExportJsonExport().catch(() => null)
botRegistryJsonMeta = await this.getBotRegistryJsonExport().catch(() => null) botRegistryJsonMeta = await this.getBotRegistryJsonExport().catch(() => null)
const botJsonHistory = await this.deliveryReceipts.listBotRegistryJsonExports(32) const botJsonHistory = await this.deliveryReceipts.listBotRegistryJsonExports(32)
botRegistryJsonRows = botJsonHistory.map((row) => { botRegistryJsonRows = botJsonHistory.map((row) => {
@@ -33887,7 +33950,10 @@ class PearcordPlatform extends EventEmitter {
archivePeerExportJsonRows, archivePeerExportJsonRows,
workerReleaseJsonMeta, workerReleaseJsonMeta,
workerReleaseJsonRows, workerReleaseJsonRows,
integrationManifestExportJsonMeta,
integrationManifestExportJsonRows, integrationManifestExportJsonRows,
guildWorkerReleaseJsonCount: (workerReleaseJsonRows || []).length,
guildIntegrationManifestJsonCount: (integrationManifestExportJsonRows || []).length,
lastComplianceSnapshot, lastComplianceSnapshot,
lastArchivePeerExport, lastArchivePeerExport,
lastIntegrationManifestExport, lastIntegrationManifestExport,
@@ -34718,6 +34784,8 @@ const { oauthGrantJsonMixin } = require('./oauth-grant-json-mixin')
const { oauthInstallTokenJsonMixin } = require('./oauth-install-token-json-mixin') const { oauthInstallTokenJsonMixin } = require('./oauth-install-token-json-mixin')
const { slashRegistryJsonMixin } = require('./slash-registry-json-mixin') const { slashRegistryJsonMixin } = require('./slash-registry-json-mixin')
const { slashInvokeAuditJsonMixin } = require('./slash-invoke-audit-json-mixin') const { slashInvokeAuditJsonMixin } = require('./slash-invoke-audit-json-mixin')
const { workerReleaseJsonMixin } = require('./worker-release-json-mixin')
const { integrationManifestJsonMixin } = require('./integration-manifest-json-mixin')
Object.assign(PearcordPlatform.prototype, pollSchedulingMixin) Object.assign(PearcordPlatform.prototype, pollSchedulingMixin)
Object.assign(PearcordPlatform.prototype, notificationsActivityMixin) Object.assign(PearcordPlatform.prototype, notificationsActivityMixin)
Object.assign(PearcordPlatform.prototype, userSettingsMixin) Object.assign(PearcordPlatform.prototype, userSettingsMixin)
@@ -34775,3 +34843,5 @@ Object.assign(PearcordPlatform.prototype, oauthGrantJsonMixin)
Object.assign(PearcordPlatform.prototype, oauthInstallTokenJsonMixin) Object.assign(PearcordPlatform.prototype, oauthInstallTokenJsonMixin)
Object.assign(PearcordPlatform.prototype, slashRegistryJsonMixin) Object.assign(PearcordPlatform.prototype, slashRegistryJsonMixin)
Object.assign(PearcordPlatform.prototype, slashInvokeAuditJsonMixin) Object.assign(PearcordPlatform.prototype, slashInvokeAuditJsonMixin)
Object.assign(PearcordPlatform.prototype, workerReleaseJsonMixin)
Object.assign(PearcordPlatform.prototype, integrationManifestJsonMixin)
+66
View File
@@ -0,0 +1,66 @@
'use strict'
const integrationManifestJsonMixin = {
_integrationManifestRegistryJsonGossipKeys: null,
_integrationManifestJsonHealWatermark: null,
_initIntegrationManifestJsonMixinState () {
if (!this._integrationManifestRegistryJsonGossipKeys) {
this._integrationManifestRegistryJsonGossipKeys = new Set()
}
},
_shouldGossipIntegrationManifestRegistryJson (slice) {
this._initIntegrationManifestJsonMixinState()
if (!slice?.guildId || !slice?.signature) return true
const hash = `${slice.guildId}:${slice.exportedAt || 0}:${slice.signature}`
if (this._integrationManifestRegistryJsonGossipKeys.has(hash)) return false
this._integrationManifestRegistryJsonGossipKeys.add(hash)
if (this._integrationManifestRegistryJsonGossipKeys.size > 8192) {
const first = this._integrationManifestRegistryJsonGossipKeys.values().next().value
if (first) this._integrationManifestRegistryJsonGossipKeys.delete(first)
}
return true
},
async _healIntegrationManifestJsonExportCursorOnPartition (guildId) {
const gid = guildId || this.guild?.guild?.id || null
const span = this.log.time('integration-manifest.json', {
spanKind: 'integration-manifest.json',
guildId: gid,
context: 'heal.integration-manifest'
})
try {
if (!gid || !this.deliveryReceipts) {
span.end({ relisted: 0, skipped: true, guildIntegrationManifestJsonCount: 0 })
return { relisted: 0, skipped: true }
}
await this._initDeliveryReceipts(gid)
const rows = await this.deliveryReceipts.listIntegrationManifestExportJsonExports(64)
let relisted = 0
for (const row of rows) {
if (this._shouldGossipIntegrationManifestRegistryJson(row)) relisted++
}
const watermark = Date.now()
this._integrationManifestJsonHealWatermark = watermark
span.end({
relisted,
watermark,
guildIntegrationManifestJsonCount: rows.length,
templateCount: rows[0]?.templateCount || 0,
bridgeKind: 'integration-manifest.json'
})
return { relisted, watermark, guildIntegrationManifestJsonCount: rows.length }
} catch (err) {
this.log.error('integration-manifest.json error', {
guildId: gid,
context: 'heal.integration-manifest',
error: err?.message || String(err)
})
span.fail(err)
return { relisted: 0, error: err?.message || String(err) }
}
}
}
module.exports = { integrationManifestJsonMixin }
+65
View File
@@ -0,0 +1,65 @@
'use strict'
const workerReleaseJsonMixin = {
_workerReleaseRegistryJsonGossipKeys: null,
_workerReleaseJsonHealWatermark: null,
_initWorkerReleaseJsonMixinState () {
if (!this._workerReleaseRegistryJsonGossipKeys) {
this._workerReleaseRegistryJsonGossipKeys = new Set()
}
},
_shouldGossipWorkerReleaseRegistryJson (slice) {
this._initWorkerReleaseJsonMixinState()
if (!slice?.guildId || !slice?.signature) return true
const hash = `${slice.guildId}:${slice.exportedAt || 0}:${slice.signature}`
if (this._workerReleaseRegistryJsonGossipKeys.has(hash)) return false
this._workerReleaseRegistryJsonGossipKeys.add(hash)
if (this._workerReleaseRegistryJsonGossipKeys.size > 8192) {
const first = this._workerReleaseRegistryJsonGossipKeys.values().next().value
if (first) this._workerReleaseRegistryJsonGossipKeys.delete(first)
}
return true
},
async _healWorkerReleaseJsonExportCursorOnPartition (guildId) {
const gid = guildId || this.guild?.guild?.id || null
const span = this.log.time('worker-release.json', {
spanKind: 'worker-release.json',
guildId: gid,
context: 'heal.worker-release'
})
try {
if (!gid || !this.deliveryReceipts) {
span.end({ relisted: 0, skipped: true, guildWorkerReleaseJsonCount: 0 })
return { relisted: 0, skipped: true }
}
await this._initDeliveryReceipts(gid)
const rows = await this.deliveryReceipts.listWorkerReleaseJsonExports(64)
let relisted = 0
for (const row of rows) {
if (this._shouldGossipWorkerReleaseRegistryJson(row)) relisted++
}
const watermark = Date.now()
this._workerReleaseJsonHealWatermark = watermark
span.end({
relisted,
watermark,
guildWorkerReleaseJsonCount: rows.length,
bridgeKind: 'worker-release.json'
})
return { relisted, watermark, guildWorkerReleaseJsonCount: rows.length }
} catch (err) {
this.log.error('worker-release.json error', {
guildId: gid,
context: 'heal.worker-release',
error: err?.message || String(err)
})
span.fail(err)
return { relisted: 0, error: err?.message || String(err) }
}
}
}
module.exports = { workerReleaseJsonMixin }