From c222a5d50b9c913de95d04d1facff750221c3f09 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 22 Apr 2026 06:55:58 +0000 Subject: [PATCH] chore(debug): temporary prints in MarmotInboundProcessor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tracing which path B→A commits take (processPrivateMessage vs applyCommit) and why past-epoch PrivateMessage events surface as Failure instead of Duplicate in tests 07/08/11/12. Will be reverted once diagnosis is complete. https://claude.ai/code/session_1469d7f4-bb66-4ffa-a44d-1dfa4b526484 --- .../vitorpamplona/quartz/marmot/MarmotInboundProcessor.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/MarmotInboundProcessor.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/MarmotInboundProcessor.kt index dc1dc9209..3c2f834f8 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/MarmotInboundProcessor.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/MarmotInboundProcessor.kt @@ -409,6 +409,7 @@ class MarmotInboundProcessor( ): GroupEventResult { // Peek at content type from the PrivateMessage header val privMsg = PrivateMessage.decodeTls(TlsReader(mlsMessage.payload)) + println("[MarmotDbg] processPrivateMessage ${groupEvent.id.take(8)} contentType=${privMsg.contentType} peekEpoch=${privMsg.epoch} curEpoch=${groupManager.getGroup(groupId)?.epoch}") return when (privMsg.contentType) { ContentType.APPLICATION -> { @@ -508,6 +509,7 @@ class MarmotInboundProcessor( retainedEpochCount = groupManager.retainedExporterSecrets(groupId).size, ) val mlsMessage = MlsMessage.decodeTls(TlsReader(mlsBytes)) + println("[MarmotDbg] applyCommit ${commitEvent.id.take(8)} wireFormat=${mlsMessage.wireFormat} groupId=${groupId.take(8)} currentEpoch=${groupManager.getGroup(groupId)?.epoch}") when (mlsMessage.wireFormat) { WireFormat.PRIVATE_MESSAGE -> { @@ -518,12 +520,15 @@ class MarmotInboundProcessor( // when it finally arrives. val privPeek = PrivateMessage.decodeTls(TlsReader(mlsMessage.payload)) val currentEpoch = groupManager.getGroup(groupId)?.epoch + println("[MarmotDbg] applyCommit ${commitEvent.id.take(8)} PRIVATE content=${privPeek.contentType} peekEpoch=${privPeek.epoch} curEpoch=$currentEpoch") when { currentEpoch != null && privPeek.epoch < currentEpoch -> { + println("[MarmotDbg] → past-epoch Duplicate") GroupEventResult.Duplicate(groupId) } currentEpoch != null && privPeek.epoch > currentEpoch -> { + println("[MarmotDbg] → future-epoch Error") GroupEventResult.Error( groupId, "PrivateMessage epoch ${privPeek.epoch} is ahead of local epoch $currentEpoch; ignoring", @@ -531,9 +536,11 @@ class MarmotInboundProcessor( } else -> { + println("[MarmotDbg] → decrypt+process") val decrypted = groupManager.decrypt(groupId, mlsMessage.toTlsBytes()) if (decrypted.contentType == ContentType.COMMIT) { val group = groupManager.getGroup(groupId) + println("[MarmotDbg] → CommitProcessed epoch=${group?.epoch}") GroupEventResult.CommitProcessed(groupId, group?.epoch ?: 0) } else { GroupEventResult.Error(