feat(platform): Phase 723 slash-registry.json and slash-invoke-audit.json mesh (v0.8.699)

Add dedicated mixins, invoke audit read/clear APIs, partition heal cursors,
view meta/counts, duplicate-at export, and span renames for slash export parity.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-06-03 08:54:41 -04:00
co-authored by Cursor
parent 3ba26ce719
commit c861e51cf3
4 changed files with 229 additions and 19 deletions
+2
View File
@@ -52,6 +52,8 @@ Application facade: one `PearcordPlatform` class that wires identity, database,
**Phase 722 (v0.8.698):** Dedicated OAuth grant & install token export JSON — `oauth-grant-json-mixin.js`, `oauth-install-token-json-mixin.js`, spans `oauth-grant.json` / `oauth-install-token.json`, `getOAuthInstallTokenExportJsonExport`, `clearOAuthInstallTokenExportJsonExports`, deep links `openOAuthGrantJson` / `openOAuthInstallTokenJson`. Bundle: `npm run test:ci-phase722`.
**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 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`.
+96 -19
View File
@@ -1803,10 +1803,10 @@ class PearcordPlatform extends EventEmitter {
const webhookExecuteJsonHeal = await this._healWebhookExecuteExportCursorOnPartition(gid).catch(() => ({
relisted: 0
}))
const slashRegistryJsonHeal = await this._healSlashRegistryExportCursorOnPartition(gid).catch(() => ({
const slashRegistryJsonHeal = await this._healSlashRegistryJsonExportCursorOnPartition(gid).catch(() => ({
relisted: 0
}))
const slashInvokeAuditJsonHeal = await this._healSlashInvokeAuditExportCursorOnPartition(gid).catch(() => ({
const slashInvokeAuditJsonHeal = await this._healSlashInvokeAuditJsonExportCursorOnPartition(gid).catch(() => ({
relisted: 0
}))
const oauthGrantJsonHeal = await this._healOAuthGrantExportCursorOnPartition(gid).catch(() => ({
@@ -18783,6 +18783,8 @@ class PearcordPlatform extends EventEmitter {
openRoleOverrideJson: !!parsed.openRoleOverrideJson,
openOAuthGrantJson: !!parsed.openOAuthGrantJson,
openOAuthInstallTokenJson: !!parsed.openOAuthInstallTokenJson,
openSlashRegistryJson: !!parsed.openSlashRegistryJson,
openSlashInvokeAuditJson: !!parsed.openSlashInvokeAuditJson,
openChannelFollowJson: !!parsed.openChannelFollowJson,
openGuildWidgetJson: !!parsed.openGuildWidgetJson
}
@@ -22361,8 +22363,8 @@ class PearcordPlatform extends EventEmitter {
async getSlashRegistryJsonExport () {
const gid = this.guild?.guild?.id || null
const span = this.log.time('slash.json', {
spanKind: 'slash.json',
const span = this.log.time('slash-registry.json', {
spanKind: 'slash-registry.json',
guildId: gid,
context: 'read'
})
@@ -22374,23 +22376,23 @@ class PearcordPlatform extends EventEmitter {
await this._initDeliveryReceipts(this.guild.guild.id)
const row = await this.deliveryReceipts.getSlashRegistryJsonExport()
if (!row?.signature) {
span.end({ guildSlashRegistryCount: row ? 1 : 0, hasSignature: false, bridgeKind: 'slash.json' })
span.end({ guildSlashRegistryJsonCount: row ? 1 : 0, hasSignature: false, bridgeKind: 'slash-registry.json' })
return row
}
const verified = verifySlashRegistryJson(exportBodyFromSlice(row) || row.jsonBody || row.jsonBody, row.signature, {
guildId: this.guild.guild.id,
relaySecret: this.guild.guild.id
})
const out = { ...row, signatureValid: verified.ok }
const out = { ...row, signatureValid: verified.ok, commandCount: row.commandCount || 0 }
span.end({
guildSlashRegistryCount: 1,
guildSlashRegistryJsonCount: 1,
hasSignature: true,
signatureValid: verified.ok,
bridgeKind: 'slash.json'
bridgeKind: 'slash-registry.json'
})
return out
} catch (err) {
this.log.error('slash.json error', {
this.log.error('slash-registry.json error', {
guildId: gid,
context: 'read',
error: err?.message || String(err)
@@ -22438,8 +22440,8 @@ class PearcordPlatform extends EventEmitter {
async pushSlashRegistryJsonToMesh () {
const gid = this.guild?.guild?.id || null
const span = this.log.time('slash.json', {
spanKind: 'slash.json',
const span = this.log.time('slash-registry.json', {
spanKind: 'slash-registry.json',
guildId: gid,
context: 'mesh.push'
})
@@ -22470,13 +22472,13 @@ class PearcordPlatform extends EventEmitter {
exportedAt: exported.exportedAt
})
span.end({
guildSlashRegistryCount: exported.commandCount || 1,
guildSlashRegistryJsonCount: exported.commandCount || 1,
meshPushed: true,
bridgeKind: 'slash.json'
bridgeKind: 'slash-registry.json'
})
return exported
} catch (err) {
this.log.error('slash.json error', {
this.log.error('slash-registry.json error', {
guildId: gid,
context: 'mesh.push',
error: err?.message || String(err)
@@ -22563,10 +22565,68 @@ class PearcordPlatform extends EventEmitter {
}
}
async getSlashInvokeAuditExportJsonExport () {
const gid = this.guild?.guild?.id || null
const span = this.log.time('slash-invoke-audit.json', {
spanKind: 'slash-invoke-audit.json',
guildId: gid,
context: 'read'
})
try {
if (!this.guild?.guild) {
span.end({ guildSlashInvokeAuditJsonCount: 0, skipped: true })
return null
}
await this._initDeliveryReceipts(this.guild.guild.id)
const row = await this.deliveryReceipts.getSlashInvokeAuditExportJsonExport()
if (!row?.signature) {
span.end({
guildSlashInvokeAuditJsonCount: row ? 1 : 0,
hasSignature: false,
bridgeKind: 'slash-invoke-audit.json'
})
return row
}
const verified = verifySlashInvokeAuditExportJson(
exportBodyFromSlice(row) || row.jsonBody || row.jsonBody,
row.signature,
{ guildId: this.guild.guild.id, relaySecret: this.guild.guild.id }
)
const out = { ...row, signatureValid: verified.ok, invokeCount: row.invokeCount || 0 }
span.end({
guildSlashInvokeAuditJsonCount: 1,
hasSignature: true,
signatureValid: verified.ok,
bridgeKind: 'slash-invoke-audit.json'
})
return out
} catch (err) {
this.log.error('slash-invoke-audit.json error', {
guildId: gid,
context: 'read',
error: err?.message || String(err)
})
span.fail(err)
throw err
}
}
async clearSlashInvokeAuditExportJsonExports () {
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 slash invoke audit JSON exports')
}
await this._initDeliveryReceipts(this.guild.guild.id)
const removed = await this.deliveryReceipts.clearSlashInvokeAuditExportJsonExports()
this.emit('slash-invoke-audit-export-json-cleared', { removed })
return { removed }
}
async pushSlashInvokeAuditExportToMesh () {
const gid = this.guild?.guild?.id || null
const span = this.log.time('slash.json', {
spanKind: 'slash.json',
const span = this.log.time('slash-invoke-audit.json', {
spanKind: 'slash-invoke-audit.json',
guildId: gid,
context: 'mesh.invoke'
})
@@ -22598,13 +22658,13 @@ class PearcordPlatform extends EventEmitter {
meshPushed: true
}
span.end({
guildSlashRegistryCount: exported.invokeCount || 0,
guildSlashInvokeAuditJsonCount: exported.invokeCount || 0,
meshPushed: true,
bridgeKind: 'slash.json'
bridgeKind: 'slash-invoke-audit.json'
})
return exported
} catch (err) {
this.log.error('slash.json error', {
this.log.error('slash-invoke-audit.json error', {
guildId: gid,
context: 'mesh.invoke',
error: err?.message || String(err)
@@ -32749,6 +32809,7 @@ class PearcordPlatform extends EventEmitter {
let lastWebhookExecuteExport = null
let slashRegistryJsonMeta = null
let slashRegistryJsonRows = []
let slashInvokeAuditExportJsonMeta = null
let slashInvokeAuditExportJsonRows = []
let lastSlashInvokeAuditExport = null
let oauthGrantJsonMeta = null
@@ -32992,6 +33053,8 @@ class PearcordPlatform extends EventEmitter {
return { ...row, signatureValid: verified.ok }
})
lastSlashInvokeAuditExport = await this.getLastSlashInvokeAuditExport()
slashInvokeAuditExportJsonMeta =
await this.getSlashInvokeAuditExportJsonExport().catch(() => null)
oauthGrantJsonMeta = await this.getOAuthGrantJsonExport().catch(() => null)
const oauthJsonHistory = await this.deliveryReceipts.listOAuthGrantJsonExports(32)
oauthGrantJsonRows = oauthJsonHistory.map((row) => {
@@ -33573,6 +33636,11 @@ class PearcordPlatform extends EventEmitter {
this._botRegistryJsonDuplicateAt = null
const webhookExecuteExportJsonDuplicateAt = this._webhookExecuteExportJsonDuplicateAt || null
this._webhookExecuteExportJsonDuplicateAt = null
const slashRegistryJsonDuplicateAt = this._slashRegistryJsonDuplicateAt || null
this._slashRegistryJsonDuplicateAt = null
const slashInvokeAuditExportJsonDuplicateAt =
this._slashInvokeAuditExportJsonDuplicateAt || null
this._slashInvokeAuditExportJsonDuplicateAt = null
const oauthGrantJsonDuplicateAt = this._oauthGrantJsonDuplicateAt || null
this._oauthGrantJsonDuplicateAt = null
const oauthInstallTokenExportJsonDuplicateAt =
@@ -33783,6 +33851,8 @@ class PearcordPlatform extends EventEmitter {
integrationManifestExportJsonDuplicateAt,
botRegistryJsonDuplicateAt,
webhookExecuteExportJsonDuplicateAt,
slashRegistryJsonDuplicateAt,
slashInvokeAuditExportJsonDuplicateAt,
oauthGrantJsonDuplicateAt,
oauthInstallTokenExportJsonDuplicateAt,
inviteLinkJsonDuplicateAt,
@@ -33831,8 +33901,11 @@ class PearcordPlatform extends EventEmitter {
lastWebhookExecuteExport,
slashRegistryJsonMeta,
slashRegistryJsonRows,
slashInvokeAuditExportJsonMeta,
slashInvokeAuditExportJsonRows,
lastSlashInvokeAuditExport,
guildSlashRegistryJsonCount: (slashRegistryJsonRows || []).length,
guildSlashInvokeAuditJsonCount: (slashInvokeAuditExportJsonRows || []).length,
oauthGrantJsonMeta,
oauthGrantJsonRows,
oauthInstallTokenExportJsonMeta,
@@ -34643,6 +34716,8 @@ const { inviteLinkJsonMixin } = require('./invite-link-json-mixin')
const { roleOverrideJsonMixin } = require('./role-override-json-mixin')
const { oauthGrantJsonMixin } = require('./oauth-grant-json-mixin')
const { oauthInstallTokenJsonMixin } = require('./oauth-install-token-json-mixin')
const { slashRegistryJsonMixin } = require('./slash-registry-json-mixin')
const { slashInvokeAuditJsonMixin } = require('./slash-invoke-audit-json-mixin')
Object.assign(PearcordPlatform.prototype, pollSchedulingMixin)
Object.assign(PearcordPlatform.prototype, notificationsActivityMixin)
Object.assign(PearcordPlatform.prototype, userSettingsMixin)
@@ -34698,3 +34773,5 @@ Object.assign(PearcordPlatform.prototype, inviteLinkJsonMixin)
Object.assign(PearcordPlatform.prototype, roleOverrideJsonMixin)
Object.assign(PearcordPlatform.prototype, oauthGrantJsonMixin)
Object.assign(PearcordPlatform.prototype, oauthInstallTokenJsonMixin)
Object.assign(PearcordPlatform.prototype, slashRegistryJsonMixin)
Object.assign(PearcordPlatform.prototype, slashInvokeAuditJsonMixin)
+66
View File
@@ -0,0 +1,66 @@
'use strict'
const slashInvokeAuditJsonMixin = {
_slashInvokeAuditRegistryJsonGossipKeys: null,
_slashInvokeAuditJsonHealWatermark: null,
_initSlashInvokeAuditJsonMixinState () {
if (!this._slashInvokeAuditRegistryJsonGossipKeys) {
this._slashInvokeAuditRegistryJsonGossipKeys = new Set()
}
},
_shouldGossipSlashInvokeAuditRegistryJson (slice) {
this._initSlashInvokeAuditJsonMixinState()
if (!slice?.guildId || !slice?.signature) return true
const hash = `${slice.guildId}:${slice.exportedAt || 0}:${slice.signature}`
if (this._slashInvokeAuditRegistryJsonGossipKeys.has(hash)) return false
this._slashInvokeAuditRegistryJsonGossipKeys.add(hash)
if (this._slashInvokeAuditRegistryJsonGossipKeys.size > 8192) {
const first = this._slashInvokeAuditRegistryJsonGossipKeys.values().next().value
if (first) this._slashInvokeAuditRegistryJsonGossipKeys.delete(first)
}
return true
},
async _healSlashInvokeAuditJsonExportCursorOnPartition (guildId) {
const gid = guildId || this.guild?.guild?.id || null
const span = this.log.time('slash-invoke-audit.json', {
spanKind: 'slash-invoke-audit.json',
guildId: gid,
context: 'heal.slash-invoke-audit'
})
try {
if (!gid || !this.deliveryReceipts) {
span.end({ relisted: 0, skipped: true, guildSlashInvokeAuditJsonCount: 0 })
return { relisted: 0, skipped: true }
}
await this._initDeliveryReceipts(gid)
const rows = await this.deliveryReceipts.listSlashInvokeAuditExportJsonExports(64)
let relisted = 0
for (const row of rows) {
if (this._shouldGossipSlashInvokeAuditRegistryJson(row)) relisted++
}
const watermark = Date.now()
this._slashInvokeAuditJsonHealWatermark = watermark
span.end({
relisted,
watermark,
guildSlashInvokeAuditJsonCount: rows.length,
invokeCount: rows[0]?.invokeCount || 0,
bridgeKind: 'slash-invoke-audit.json'
})
return { relisted, watermark, guildSlashInvokeAuditJsonCount: rows.length }
} catch (err) {
this.log.error('slash-invoke-audit.json error', {
guildId: gid,
context: 'heal.slash-invoke-audit',
error: err?.message || String(err)
})
span.fail(err)
return { relisted: 0, error: err?.message || String(err) }
}
}
}
module.exports = { slashInvokeAuditJsonMixin }
+65
View File
@@ -0,0 +1,65 @@
'use strict'
const slashRegistryJsonMixin = {
_slashRegistryExportJsonGossipKeys: null,
_slashRegistryJsonHealWatermark: null,
_initSlashRegistryJsonMixinState () {
if (!this._slashRegistryExportJsonGossipKeys) {
this._slashRegistryExportJsonGossipKeys = new Set()
}
},
_shouldGossipSlashRegistryExportJson (slice) {
this._initSlashRegistryJsonMixinState()
if (!slice?.guildId || !slice?.signature) return true
const hash = `${slice.guildId}:${slice.exportedAt || 0}:${slice.signature}`
if (this._slashRegistryExportJsonGossipKeys.has(hash)) return false
this._slashRegistryExportJsonGossipKeys.add(hash)
if (this._slashRegistryExportJsonGossipKeys.size > 8192) {
const first = this._slashRegistryExportJsonGossipKeys.values().next().value
if (first) this._slashRegistryExportJsonGossipKeys.delete(first)
}
return true
},
async _healSlashRegistryJsonExportCursorOnPartition (guildId) {
const gid = guildId || this.guild?.guild?.id || null
const span = this.log.time('slash-registry.json', {
spanKind: 'slash-registry.json',
guildId: gid,
context: 'heal.slash-registry'
})
try {
if (!gid || !this.deliveryReceipts) {
span.end({ relisted: 0, skipped: true, guildSlashRegistryJsonCount: 0 })
return { relisted: 0, skipped: true }
}
await this._initDeliveryReceipts(gid)
const rows = await this.deliveryReceipts.listSlashRegistryJsonExports(64)
let relisted = 0
for (const row of rows) {
if (this._shouldGossipSlashRegistryExportJson(row)) relisted++
}
const watermark = Date.now()
this._slashRegistryJsonHealWatermark = watermark
span.end({
relisted,
watermark,
guildSlashRegistryJsonCount: rows.length,
bridgeKind: 'slash-registry.json'
})
return { relisted, watermark, guildSlashRegistryJsonCount: rows.length }
} catch (err) {
this.log.error('slash-registry.json error', {
guildId: gid,
context: 'heal.slash-registry',
error: err?.message || String(err)
})
span.fail(err)
return { relisted: 0, error: err?.message || String(err) }
}
}
}
module.exports = { slashRegistryJsonMixin }