refactor(platform): organize mixins into category directories

Move 136 prototype mixins under mixins/domain, json-export, and
runtime/* so the package root stays navigable. Manifest assign order
is unchanged; apply-platform-mixins and runtime registry paths updated.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-06-03 17:42:26 -04:00
co-authored by Cursor
parent 08bdbf4d17
commit a5dba86570
142 changed files with 1111 additions and 393 deletions
+107
View File
@@ -0,0 +1,107 @@
'use strict'
const deliveryMixin = {
_deliveryReceiptGossipKeys: null,
_receiptRegistryHealWatermark: null,
_failureDigestHealWatermark: null,
_initDeliveryMixinState () {
if (!this._deliveryReceiptGossipKeys) {
this._deliveryReceiptGossipKeys = new Set()
}
},
_shouldGossipDeliveryReceipt (receipt) {
this._initDeliveryMixinState()
if (!receipt?.guildId || !receipt?.id) return true
const hash = `${receipt.guildId}:${receipt.id}:${receipt.hookId || ''}:${receipt.status || ''}:${receipt.eventType || ''}:${receipt.at || 0}`
if (this._deliveryReceiptGossipKeys.has(hash)) return false
this._deliveryReceiptGossipKeys.add(hash)
if (this._deliveryReceiptGossipKeys.size > 8192) {
const first = this._deliveryReceiptGossipKeys.values().next().value
if (first) this._deliveryReceiptGossipKeys.delete(first)
}
return true
},
async _healReceiptRegistryOnPartition (guildId) {
const gid = guildId || this.guild?.guild?.id || null
const span = this.log.time('delivery.receipt', {
spanKind: 'delivery.receipt',
guildId: gid,
context: 'heal.registry'
})
try {
if (!gid || !this.deliveryReceipts) {
span.end({ relisted: 0, skipped: true, guildReceiptCount: 0 })
return { relisted: 0, skipped: true }
}
await this._initDeliveryReceipts(gid)
const rows = await this.deliveryReceipts.listRecent(512)
let relisted = 0
for (const row of rows) {
if (this._shouldGossipDeliveryReceipt(row)) relisted++
}
const watermark = Date.now()
this._receiptRegistryHealWatermark = watermark
span.end({
relisted,
watermark,
guildReceiptCount: rows.length,
bridgeKind: 'delivery.receipt'
})
return { relisted, watermark, guildReceiptCount: rows.length }
} catch (err) {
this.log.error('delivery.receipt error', {
guildId: gid,
context: 'heal.registry',
error: err?.message || String(err)
})
span.fail(err)
return { relisted: 0, error: err?.message || String(err) }
}
},
async _healFailureDigestCursorOnPartition (guildId) {
const gid = guildId || this.guild?.guild?.id || null
const span = this.log.time('delivery.receipt', {
spanKind: 'delivery.receipt',
guildId: gid,
context: 'heal.digest'
})
try {
if (!gid) {
span.end({ relisted: 0, skipped: true, guildReceiptCount: 0 })
return { relisted: 0, skipped: true }
}
await this._initDeliveryReceipts(gid)
const digest = await this._computeHookFailureDigest().catch(() => null)
const watermark = Date.now()
this._failureDigestHealWatermark = watermark
span.end({
relisted: 0,
watermark,
guildReceiptCount: (await this.deliveryReceipts.listRecent(64)).length,
digestFailures: digest?.totalFailures || 0,
guildCount: (this.guilds || []).length,
activeChannelId: this.activeChannelId || null,
bridgeKind: 'delivery.receipt'
})
return {
relisted: 0,
watermark,
guildReceiptCount: (await this.deliveryReceipts.listRecent(64)).length
}
} catch (err) {
this.log.error('delivery.receipt error', {
guildId: gid,
context: 'heal.digest',
error: err?.message || String(err)
})
span.fail(err)
return { relisted: 0, error: err?.message || String(err) }
}
}
}
module.exports = { deliveryMixin }