feat(phase725): bot-registry.json spans and dedicated heal mixin
Add bot-registry-json-mixin with partition heal cursors, migrate bot registry platform spans from bot.json, and expose guildBotRegistryJsonCount in the guild view (v0.8.701). Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -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 725 (v0.8.701):** Dedicated bot registry & webhook execute export JSON — `bot-registry-json-mixin.js`, `webhook-json-mixin.js`, spans `bot-registry.json` / `webhook.json`, deep links `openBotRegistryJson` / `openWebhookExecuteExportJson`. Bundle: `npm run test:ci-phase725`.
|
||||||
|
|
||||||
**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 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`.
|
||||||
|
|||||||
+2
-106
@@ -1,113 +1,9 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
/** @deprecated Phase 725 — registry heal in bot-registry-json-mixin; webhook heal in webhook-json-mixin */
|
||||||
const botJsonMixin = {
|
const botJsonMixin = {
|
||||||
_botRegistryJsonGossipKeys: null,
|
_shouldGossipWebhookExecuteExportJsonLegacy (slice) {
|
||||||
_botJsonHealWatermark: null,
|
|
||||||
_webhookExecuteJsonHealWatermark: null,
|
|
||||||
|
|
||||||
_initBotJsonMixinState () {
|
|
||||||
if (!this._botRegistryJsonGossipKeys) {
|
|
||||||
this._botRegistryJsonGossipKeys = new Set()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_shouldGossipBotRegistryJson (slice) {
|
|
||||||
this._initBotJsonMixinState()
|
|
||||||
if (!slice?.guildId || !slice?.signature) return true
|
|
||||||
const hash = `${slice.guildId}:${slice.exportedAt || 0}:${slice.signature}`
|
|
||||||
if (this._botRegistryJsonGossipKeys.has(hash)) return false
|
|
||||||
this._botRegistryJsonGossipKeys.add(hash)
|
|
||||||
if (this._botRegistryJsonGossipKeys.size > 8192) {
|
|
||||||
const first = this._botRegistryJsonGossipKeys.values().next().value
|
|
||||||
if (first) this._botRegistryJsonGossipKeys.delete(first)
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
},
|
|
||||||
|
|
||||||
_shouldGossipWebhookExecuteExportJson (slice) {
|
|
||||||
this._initBotJsonMixinState()
|
|
||||||
if (!slice?.guildId || !slice?.signature) return true
|
|
||||||
const hash = `webhook:${slice.guildId}:${slice.exportedAt || 0}:${slice.signature}`
|
|
||||||
if (this._botRegistryJsonGossipKeys.has(hash)) return false
|
|
||||||
this._botRegistryJsonGossipKeys.add(hash)
|
|
||||||
return true
|
|
||||||
},
|
|
||||||
|
|
||||||
async _healBotRegistryExportCursorOnPartition (guildId) {
|
|
||||||
const gid = guildId || this.guild?.guild?.id || null
|
|
||||||
const span = this.log.time('bot.json', {
|
|
||||||
spanKind: 'bot.json',
|
|
||||||
guildId: gid,
|
|
||||||
context: 'heal.registry'
|
|
||||||
})
|
|
||||||
try {
|
|
||||||
if (!gid || !this.deliveryReceipts) {
|
|
||||||
span.end({ relisted: 0, skipped: true, guildBotRegistryCount: 0 })
|
|
||||||
return { relisted: 0, skipped: true }
|
|
||||||
}
|
|
||||||
await this._initDeliveryReceipts(gid)
|
|
||||||
const rows = await this.deliveryReceipts.listBotRegistryJsonExports(64)
|
|
||||||
let relisted = 0
|
|
||||||
for (const row of rows) {
|
|
||||||
if (this._shouldGossipBotRegistryJson(row)) relisted++
|
|
||||||
}
|
|
||||||
const watermark = Date.now()
|
|
||||||
this._botJsonHealWatermark = watermark
|
|
||||||
span.end({
|
|
||||||
relisted,
|
|
||||||
watermark,
|
|
||||||
guildBotRegistryCount: rows.length,
|
|
||||||
bridgeKind: 'bot.json'
|
|
||||||
})
|
|
||||||
return { relisted, watermark, guildBotRegistryCount: rows.length }
|
|
||||||
} catch (err) {
|
|
||||||
this.log.error('bot.json error', {
|
|
||||||
guildId: gid,
|
|
||||||
context: 'heal.registry',
|
|
||||||
error: err?.message || String(err)
|
|
||||||
})
|
|
||||||
span.fail(err)
|
|
||||||
return { relisted: 0, error: err?.message || String(err) }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async _healWebhookExecuteExportCursorOnPartition (guildId) {
|
|
||||||
const gid = guildId || this.guild?.guild?.id || null
|
|
||||||
const span = this.log.time('bot.json', {
|
|
||||||
spanKind: 'bot.json',
|
|
||||||
guildId: gid,
|
|
||||||
context: 'heal.execute'
|
|
||||||
})
|
|
||||||
try {
|
|
||||||
if (!gid || !this.deliveryReceipts) {
|
|
||||||
span.end({ relisted: 0, skipped: true, guildBotRegistryCount: 0 })
|
|
||||||
return { relisted: 0, skipped: true }
|
|
||||||
}
|
|
||||||
await this._initDeliveryReceipts(gid)
|
|
||||||
const rows = await this.deliveryReceipts.listWebhookExecuteExportJsonExports(64)
|
|
||||||
let relisted = 0
|
|
||||||
for (const row of rows) {
|
|
||||||
if (this._shouldGossipWebhookExecuteExportJson(row)) relisted++
|
|
||||||
}
|
|
||||||
const watermark = Date.now()
|
|
||||||
this._webhookExecuteJsonHealWatermark = watermark
|
|
||||||
span.end({
|
|
||||||
relisted,
|
|
||||||
watermark,
|
|
||||||
guildBotRegistryCount: rows.length,
|
|
||||||
webhookCount: rows[0]?.webhookCount || 0,
|
|
||||||
bridgeKind: 'bot.json'
|
|
||||||
})
|
|
||||||
return { relisted, watermark, webhookCount: rows[0]?.webhookCount || 0 }
|
|
||||||
} catch (err) {
|
|
||||||
this.log.error('bot.json error', {
|
|
||||||
guildId: gid,
|
|
||||||
context: 'heal.execute',
|
|
||||||
error: err?.message || String(err)
|
|
||||||
})
|
|
||||||
span.fail(err)
|
|
||||||
return { relisted: 0, error: err?.message || String(err) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const botRegistryJsonMixin = {
|
||||||
|
_botRegistryExportJsonGossipKeys: null,
|
||||||
|
_botRegistryJsonHealWatermark: null,
|
||||||
|
|
||||||
|
_initBotRegistryJsonMixinState () {
|
||||||
|
if (!this._botRegistryExportJsonGossipKeys) {
|
||||||
|
this._botRegistryExportJsonGossipKeys = new Set()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_shouldGossipBotRegistryExportJson (slice) {
|
||||||
|
this._initBotRegistryJsonMixinState()
|
||||||
|
if (!slice?.guildId || !slice?.signature) return true
|
||||||
|
const hash = `${slice.guildId}:${slice.exportedAt || 0}:${slice.signature}`
|
||||||
|
if (this._botRegistryExportJsonGossipKeys.has(hash)) return false
|
||||||
|
this._botRegistryExportJsonGossipKeys.add(hash)
|
||||||
|
if (this._botRegistryExportJsonGossipKeys.size > 8192) {
|
||||||
|
const first = this._botRegistryExportJsonGossipKeys.values().next().value
|
||||||
|
if (first) this._botRegistryExportJsonGossipKeys.delete(first)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
|
||||||
|
async _healBotRegistryJsonExportCursorOnPartition (guildId) {
|
||||||
|
const gid = guildId || this.guild?.guild?.id || null
|
||||||
|
const span = this.log.time('bot-registry.json', {
|
||||||
|
spanKind: 'bot-registry.json',
|
||||||
|
guildId: gid,
|
||||||
|
context: 'heal.bot-registry'
|
||||||
|
})
|
||||||
|
try {
|
||||||
|
if (!gid || !this.deliveryReceipts) {
|
||||||
|
span.end({ relisted: 0, skipped: true, guildBotRegistryJsonCount: 0 })
|
||||||
|
return { relisted: 0, skipped: true }
|
||||||
|
}
|
||||||
|
await this._initDeliveryReceipts(gid)
|
||||||
|
const rows = await this.deliveryReceipts.listBotRegistryJsonExports(64)
|
||||||
|
let relisted = 0
|
||||||
|
for (const row of rows) {
|
||||||
|
if (this._shouldGossipBotRegistryExportJson(row)) relisted++
|
||||||
|
}
|
||||||
|
const watermark = Date.now()
|
||||||
|
this._botRegistryJsonHealWatermark = watermark
|
||||||
|
span.end({
|
||||||
|
relisted,
|
||||||
|
watermark,
|
||||||
|
guildBotRegistryJsonCount: rows.length,
|
||||||
|
bridgeKind: 'bot-registry.json'
|
||||||
|
})
|
||||||
|
return { relisted, watermark, guildBotRegistryJsonCount: rows.length }
|
||||||
|
} catch (err) {
|
||||||
|
this.log.error('bot-registry.json error', {
|
||||||
|
guildId: gid,
|
||||||
|
context: 'heal.bot-registry',
|
||||||
|
error: err?.message || String(err)
|
||||||
|
})
|
||||||
|
span.fail(err)
|
||||||
|
return { relisted: 0, error: err?.message || String(err) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { botRegistryJsonMixin }
|
||||||
@@ -1797,10 +1797,10 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
const integrationManifestJsonHeal = await this._healIntegrationManifestJsonExportCursorOnPartition(gid).catch(() => ({
|
const integrationManifestJsonHeal = await this._healIntegrationManifestJsonExportCursorOnPartition(gid).catch(() => ({
|
||||||
relisted: 0
|
relisted: 0
|
||||||
}))
|
}))
|
||||||
const botRegistryJsonHeal = await this._healBotRegistryExportCursorOnPartition(gid).catch(() => ({
|
const botRegistryJsonHeal = await this._healBotRegistryJsonExportCursorOnPartition(gid).catch(() => ({
|
||||||
relisted: 0
|
relisted: 0
|
||||||
}))
|
}))
|
||||||
const webhookExecuteJsonHeal = await this._healWebhookExecuteExportCursorOnPartition(gid).catch(() => ({
|
const webhookExecuteJsonHeal = await this._healWebhookExecuteJsonExportCursorOnPartition(gid).catch(() => ({
|
||||||
relisted: 0
|
relisted: 0
|
||||||
}))
|
}))
|
||||||
const slashRegistryJsonHeal = await this._healSlashRegistryJsonExportCursorOnPartition(gid).catch(() => ({
|
const slashRegistryJsonHeal = await this._healSlashRegistryJsonExportCursorOnPartition(gid).catch(() => ({
|
||||||
@@ -14146,20 +14146,20 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
|
|
||||||
async getBotRegistryJsonExport () {
|
async getBotRegistryJsonExport () {
|
||||||
const gid = this.guild?.guild?.id || null
|
const gid = this.guild?.guild?.id || null
|
||||||
const span = this.log.time('bot.json', {
|
const span = this.log.time('bot-registry.json', {
|
||||||
spanKind: 'bot.json',
|
spanKind: 'bot-registry.json',
|
||||||
guildId: gid,
|
guildId: gid,
|
||||||
context: 'read'
|
context: 'read'
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
if (!this.guild?.guild) {
|
if (!this.guild?.guild) {
|
||||||
span.end({ guildBotRegistryCount: 0, skipped: true })
|
span.end({ guildBotRegistryJsonCount: 0, skipped: true })
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
await this._initDeliveryReceipts(this.guild.guild.id)
|
await this._initDeliveryReceipts(this.guild.guild.id)
|
||||||
const row = await this.deliveryReceipts.getBotRegistryJsonExport()
|
const row = await this.deliveryReceipts.getBotRegistryJsonExport()
|
||||||
if (!row?.signature) {
|
if (!row?.signature) {
|
||||||
span.end({ guildBotRegistryCount: row ? 1 : 0, hasSignature: false, bridgeKind: 'bot.json' })
|
span.end({ guildBotRegistryJsonCount: row ? 1 : 0, hasSignature: false, bridgeKind: 'bot-registry.json' })
|
||||||
return row
|
return row
|
||||||
}
|
}
|
||||||
const verified = verifyBotRegistryJson(exportBodyFromSlice(row) || row.jsonBody || row.jsonBody, row.signature, {
|
const verified = verifyBotRegistryJson(exportBodyFromSlice(row) || row.jsonBody || row.jsonBody, row.signature, {
|
||||||
@@ -14168,14 +14168,14 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
})
|
})
|
||||||
const out = { ...row, signatureValid: verified.ok }
|
const out = { ...row, signatureValid: verified.ok }
|
||||||
span.end({
|
span.end({
|
||||||
guildBotRegistryCount: 1,
|
guildBotRegistryJsonCount: 1,
|
||||||
hasSignature: true,
|
hasSignature: true,
|
||||||
signatureValid: verified.ok,
|
signatureValid: verified.ok,
|
||||||
bridgeKind: 'bot.json'
|
bridgeKind: 'bot-registry.json'
|
||||||
})
|
})
|
||||||
return out
|
return out
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.log.error('bot.json error', {
|
this.log.error('bot-registry.json error', {
|
||||||
guildId: gid,
|
guildId: gid,
|
||||||
context: 'read',
|
context: 'read',
|
||||||
error: err?.message || String(err)
|
error: err?.message || String(err)
|
||||||
@@ -14222,8 +14222,8 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
|
|
||||||
async pushBotRegistryJsonToMesh () {
|
async pushBotRegistryJsonToMesh () {
|
||||||
const gid = this.guild?.guild?.id || null
|
const gid = this.guild?.guild?.id || null
|
||||||
const span = this.log.time('bot.json', {
|
const span = this.log.time('bot-registry.json', {
|
||||||
spanKind: 'bot.json',
|
spanKind: 'bot-registry.json',
|
||||||
guildId: gid,
|
guildId: gid,
|
||||||
context: 'mesh.push'
|
context: 'mesh.push'
|
||||||
})
|
})
|
||||||
@@ -14254,13 +14254,13 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
exportedAt: exported.exportedAt
|
exportedAt: exported.exportedAt
|
||||||
})
|
})
|
||||||
span.end({
|
span.end({
|
||||||
guildBotRegistryCount: exported.botCount || 1,
|
guildBotRegistryJsonCount: exported.botCount || 1,
|
||||||
meshPushed: true,
|
meshPushed: true,
|
||||||
bridgeKind: 'bot.json'
|
bridgeKind: 'bot-registry.json'
|
||||||
})
|
})
|
||||||
return exported
|
return exported
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.log.error('bot.json error', {
|
this.log.error('bot-registry.json error', {
|
||||||
guildId: gid,
|
guildId: gid,
|
||||||
context: 'mesh.push',
|
context: 'mesh.push',
|
||||||
error: err?.message || String(err)
|
error: err?.message || String(err)
|
||||||
@@ -33959,6 +33959,7 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
lastIntegrationManifestExport,
|
lastIntegrationManifestExport,
|
||||||
botRegistryJsonMeta,
|
botRegistryJsonMeta,
|
||||||
botRegistryJsonRows,
|
botRegistryJsonRows,
|
||||||
|
guildBotRegistryJsonCount: (botRegistryJsonRows || []).length,
|
||||||
webhookExecuteExportJsonRows,
|
webhookExecuteExportJsonRows,
|
||||||
webhookExecuteExportJsonMeta,
|
webhookExecuteExportJsonMeta,
|
||||||
guildWebhookExecuteEntries,
|
guildWebhookExecuteEntries,
|
||||||
@@ -34748,6 +34749,7 @@ const { digestJsonMixin } = require('./digest-json-mixin')
|
|||||||
const { relayJsonMixin } = require('./relay-json-mixin')
|
const { relayJsonMixin } = require('./relay-json-mixin')
|
||||||
const { workerJsonMixin } = require('./worker-json-mixin')
|
const { workerJsonMixin } = require('./worker-json-mixin')
|
||||||
const { botJsonMixin } = require('./bot-json-mixin')
|
const { botJsonMixin } = require('./bot-json-mixin')
|
||||||
|
const { botRegistryJsonMixin } = require('./bot-registry-json-mixin')
|
||||||
const { slashJsonMixin } = require('./slash-json-mixin')
|
const { slashJsonMixin } = require('./slash-json-mixin')
|
||||||
const { oauthJsonMixin } = require('./oauth-json-mixin')
|
const { oauthJsonMixin } = require('./oauth-json-mixin')
|
||||||
const { inviteJsonMixin } = require('./invite-json-mixin')
|
const { inviteJsonMixin } = require('./invite-json-mixin')
|
||||||
@@ -34807,6 +34809,7 @@ Object.assign(PearcordPlatform.prototype, digestJsonMixin)
|
|||||||
Object.assign(PearcordPlatform.prototype, relayJsonMixin)
|
Object.assign(PearcordPlatform.prototype, relayJsonMixin)
|
||||||
Object.assign(PearcordPlatform.prototype, workerJsonMixin)
|
Object.assign(PearcordPlatform.prototype, workerJsonMixin)
|
||||||
Object.assign(PearcordPlatform.prototype, botJsonMixin)
|
Object.assign(PearcordPlatform.prototype, botJsonMixin)
|
||||||
|
Object.assign(PearcordPlatform.prototype, botRegistryJsonMixin)
|
||||||
Object.assign(PearcordPlatform.prototype, slashJsonMixin)
|
Object.assign(PearcordPlatform.prototype, slashJsonMixin)
|
||||||
Object.assign(PearcordPlatform.prototype, oauthJsonMixin)
|
Object.assign(PearcordPlatform.prototype, oauthJsonMixin)
|
||||||
Object.assign(PearcordPlatform.prototype, inviteJsonMixin)
|
Object.assign(PearcordPlatform.prototype, inviteJsonMixin)
|
||||||
|
|||||||
Reference in New Issue
Block a user