From d05742a8b6697dd3f53bc407496becc9bdb98615 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 23 Apr 2026 00:18:56 +0000 Subject: [PATCH] debug(marmot): log publishMarmotKeyPackages path for Test 13 diagnosis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test 13 (KeyPackage rotation) fails with "no new KP event_id observed" — the interop log shows three `needsKeyPackageRotation=true` triggers (once per group join), each of which invokes `account.publishMarmotKeyPackages()` from `processMarmotWelcomeFlow`, but no subsequent `kind:30443` publish ever appears in the logcat. `publishMarmotKeyPackages` was completely silent: no-op guards, the needsRotation check, the rotated-events count, and the per-event publish all ran without a log line. We can't tell whether the rotation produces events that never reach a relay, produces zero events, short-circuits on needsRotation=false, or is never called at all. Mirror the addMarmotGroupMember log pattern: entry guards (manager null / not writeable), the needsRotation + relay count at decision time, the rotateConsumedKeyPackages produce-count, and a per-event publish line with id + target relay list. Next rerun of Test 13 will tell us which branch is silently dropping the rotation. --- .../vitorpamplona/amethyst/model/Account.kt | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index 7fd284b0c..e91446a4e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -2167,15 +2167,33 @@ class Account( * Publish or rotate KeyPackage events. */ suspend fun publishMarmotKeyPackages() { - val manager = marmotManager ?: return - if (!isWriteable()) return + val manager = + marmotManager ?: run { + Log.w("MarmotDbg") { "publishMarmotKeyPackages: marmotManager is NULL — no-op" } + return + } + if (!isWriteable()) { + Log.w("MarmotDbg") { "publishMarmotKeyPackages: account is not writeable — no-op" } + return + } val relays = keyPackagePublishRelays() + val needsRotation = manager.needsKeyPackageRotation() + Log.d("MarmotDbg") { + "publishMarmotKeyPackages: needsRotation=$needsRotation relays=${relays.size}" + } - if (manager.needsKeyPackageRotation()) { + if (needsRotation) { val rotatedEvents = manager.rotateConsumedKeyPackages(relays.toList()) + Log.d("MarmotDbg") { + "publishMarmotKeyPackages: rotateConsumedKeyPackages produced ${rotatedEvents.size} event(s)" + } rotatedEvents.forEach { event -> cache.justConsumeMyOwnEvent(event) + Log.d("MarmotDbg") { + "publishMarmotKeyPackages: publishing rotated kind:${event.kind} id=${event.id.take(8)}… " + + "→ ${relays.size} relay(s): ${relays.map { it.url }}" + } client.publish(event, relays) } }