Status, the notes under each phase, a CLAUDE.md rule for stamping every NIP-17 payload, and the docs index. The device run is not done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 KiB
Disappearing NIP-17 messages, one day by default
A plan to give every NIP-17 event Giza sends a NIP-40 expiration, with no exceptions. That
includes what a person writes, what a group sends, and every ceremony round, signing round,
confederation statement and Welcome that travels the same way. What a person writes expires one
day after it is written unless they choose otherwise. When that time comes, both people's Giza
deletes it, and the relays holding the wrap are asked to drop it. Protocol messages expire too,
on a clock that is never shorter than the protocol needs (D2). A person can change the length
for what they write, or turn it off. They can do this for everything they send, or for one
conversation.
Written against 3b0b3c9a on 2026-11-22. Built, Phases 0 to 7, on
claude/disappearing-messages, one commit per phase. The device run (Phase 8) has not been done.
It is not behind a flag: a build with this in it stamps a one-day expiry on what everyone
writes in NIP-17 from the first message after the upgrade. Revised the same day as it was written:
protocol messages were first left out, and now expire too. Each phase says what was built and
where it differs from the plan.
Read marmot-direct-messages.md before changing anything on the
send path. It explains why a GiftWrapPayload row with a null seal id leaves the device, and
that rule is the one this plan touches most. frost-session-resend.md
already treats a NIP-40 expiry as one of the reasons a member can miss a round, and that is
why signing rounds can expire with the person's own setting. group-threshold-ecdh.md
and group-inbox.md cover the two ways a group sends NIP-17.
What the NIPs say, and where they disagree
- NIP-17: clients "MAY offer disappearing messages by setting an
expirationtag in the gift wrap of each receiver". The tag "SHOULD be included on thekind:13seal as well, in case it leaks". NIP-17 says nothing about the rumor (kind 14), and it defines no event for a shared or preferred expiry. Each sender decides for their own messages. - NIP-59: "Tags MUST always be empty in a
kind:13." This conflicts directly with NIP-17's seal advice. NIP-59 also says that when both layers carry expirations, each layer should use its own random timestamp. - NIP-40: the expiration is an absolute unix time. Relays "SHOULD drop" events that are already expired when published, and "SHOULD NOT send expired events to clients", but they "MAY persist them indefinitely". Clients "SHOULD ignore events that have expired" and "SHOULD NOT send expiration events to relays that do not support this NIP". NIP-40 also says plainly that expiration is not a security feature.
The plan follows from these. The rumor's expiration is what Giza obeys, because it is the only copy the sender signed (through the seal) and the only one the recipient can trust. The wrap's expiration is a request to relays. The seal stays empty (D5).
Where NIP-17 leaves Giza today
Every outbound gift wrap comes from one of these sources, and none of them sets an expiration today. Under this plan, all of them do.
| Path | Builds the wrap | What it carries | Clock (D2) |
|---|---|---|---|
| A person writing in a NIP-17 room | DatabaseChatRepository.sendChatMessage → GiftWrapPayload → sealGiftWrapPayload → NostrNip17Dao.persistAndBroadcastGiftWrap |
kind 14 and the other kinds a person writes | the person's policy |
| The notification quick reply | NotificationActions → sendChatMessage |
kind 14 | the person's policy |
| A group writing to someone | GroupDmSender.wrapOwed (GiftWrapEvent.create) |
a rumor signed by the group, sealed by threshold ECDH | the person's policy, signed by the quorum |
| A group's inbox reply | InboxReplies.wrapAndOwe (InboxWrap.wrap) |
a rumor signed by the group, sealed to the NIP-4E key | the person's policy, signed by the quorum |
| Key ceremony rounds | GiftWrapPayload rows from ChillDkgRitualManager |
DKG rounds | protocol floor |
| Signing rounds | GiftWrapPayload rows from FrostSigningManager |
FROST proposal, nonce, signer set, partials, signature, failure, decline | protocol floor |
| Confederation statements | GiftWrapPayload rows from ConfederationRitualManager |
statements, which already carry an expiration of their own |
the proposal's own expiry |
| The Marmot Welcome | MarmotOutboundDao.deliveryWelcome → GiftWrapPayload |
kind 444 | protocol floor |
Three other facts matter here:
sealGiftWrapPayloadseals a copy to every participant, including the sender, so a second device of the sender's can read their own messages. NIP-17 suggests leaving out the sender's copy as one way to make messages disappear. This plan keeps the copy (D5).- Ceremonies read their own rounds back out of the payload table. In a NIP-17 room,
ChillDkgRitualManager(around line 610),ConfederationRitualManager(around line 603) andFrostSigningManager(around line 869) rebuild a session from theGiftWrapPayloadrows stored for it.FrostSigningManager.isQueued(around line 3241) uses the same table to avoid queueing a round twice. Deleting a protocol payload is therefore not like deleting a chat line. It is what D6 and Phase 5 deal with. - The only NIP-17 relay is
Relays.DefaultDMRelayList = [wss://ephemeral.mantra.press]. Sending to the recipient's kind 10050 relays is written inpersistAndBroadcastGiftWrapbut commented out. Whether the relay drops anything depends on that one relay (D8).
Marmot (MLS) rooms are not NIP-17 and are out of scope. Their messages travel as kind 445, which
already carries the group's own retention (MlsGroup.retentionSeconds,
MarmotInnerEvent.disappearingExpiration). The retention applies to every inner kind there,
ceremony rounds included. That is the precedent this plan follows for NIP-17 rooms. A Marmot
direct message is a NIP-59 wrap that never reaches a relay. See D11.
Decisions
D1. The sender decides, and the setting is about the messages you send
NIP-17 has no shared conversation timer. Each message carries its sender's choice, so the setting is worded as "Messages you send disappear after…" everywhere. It is never worded as "this chat disappears". Two Giza users who both keep the default will see the whole conversation disappear after a day. A peer who chooses a week makes their own messages last a week. A peer on a client without expirations sends messages that never expire, and Giza does not invent an expiry for them.
A local "also delete what I receive after…" retention is a separate feature. It is listed under Out of scope so it does not get mixed in here.
D2. Everything expires, on one of two clocks
Every event that goes into a NIP-17 wrap gets an expiration. There is no allowlist and no exception. What differs is how long it lives:
- What a person writes (kinds 14, 15, 7, and 5 when it deletes one of these) expires after the person's policy (D3, D4). The policy can be Off, and Off means these messages carry no expiration.
- Protocol messages expire after
max(policy, floor), where each protocol has its own floor. They always expire. Off turns off expiry for what a person writes, not for ceremonies. A ceremony round that lived forever on a relay would be the one exception to "everything expires", and the point of this revision is that there are none.
The floors start from each protocol's own timeline. Phase 0 checks them against the code:
| Protocol | Kinds | Floor | Why |
|---|---|---|---|
| FROST signing | 30320–30325, 30330 | 1 day | frost-session-resend.md already handles a round that expired off a relay. The proposer resends, and a fresh event carries a fresh expiry. The floor only stops a 1-hour setting from making every signing a race |
| Key ceremonies (DKG, inbox key, share refresh) | each ritual's ALL set |
7 days | A ceremony waits for every admin, and an admin can be away for days. There is no resend for a DKG round |
| Confederation statements | the confederation statement kinds | the proposal's expiresAt (at most 30 days, ConfederationKinds.MAX_EXPIRY_SECONDS) |
The rumor already carries ["expiration", expiresAt], meaning the proposal lapses then. That tag is already NIP-40-shaped, so it is the rumor's expiration. Giza does not add a second one (D5) |
| Marmot Welcome | 444 | 7 days | The invitee holds no group state yet and may not open the app for days |
| Anything not listed | any other kind | 7 days | A new kind still expires, and a test fails until someone classifies it on purpose (Phase 1) |
DisappearingMessages.classOf(kind) returns Written or Protocol(floor). Classifying a new
kind is a one-line change with a reason. Forgetting to classify it gives it the safe default of
seven days, not "never".
Expiring on the relay is not the same as deleting on the device. A protocol payload's rows stay on the device until its session has finished and its expiry has passed (D6). The keys, shares, signatures and session records a ceremony produces are not messages. They do not expire, because they are the result the ceremony existed to produce.
D3. One day by default, presets, and a bounded custom length
The presets are Off, 1 hour, 8 hours, 1 day (default), 1 week, 4 weeks, plus Custom, which takes a number and a unit (minutes, hours, days). Custom allows 5 minutes to 365 days.
- The 5-minute floor covers clock skew between two phones and the time it takes a message to be delivered while the notary is catching up. Below that, a message can arrive already expired and be dropped (D6).
- The 365-day ceiling keeps the value inside a range that relays and other clients handle without surprises, and still lets "a long time" be a real choice.
Values are stored as seconds. 0 means Off and null means "follow the default" (D4).
D4. A default for the identity, and an override per conversation
- The identity's default lives in the aux database, keyed by
userPublicKey. This is the same place and shape asNotificationLedger, whichNotificationSettingsStorealready reads and writes. A new identity starts at 86 400 seconds. So does an existing identity when the migration runs (D9). - A conversation's override is a nullable
ChatRoom.disappearingMessageSecs.nullfollows the default,0is Off for this conversation only, and any other value is that many seconds. Only NIP-17 rooms show the override (mlsGroupState == null). A quorum's or confederation's NIP-17 room has an override like any other room, and its protocol messages read their policy from it.
The expiry for a message is worked out once, when it is queued:
DisappearingMessages.expiryFor(kind, createdAt, policy = room.disappearingMessageSecs ?: identityDefault).
The result is written into the payload's tags. Changing the setting later never changes a message
that has already been sent. It cannot, because the tag is part of the rumor's id.
D5. Which layers get a timestamp, and which timestamp
- Rumor:
["expiration", expiry], worked out from the rumor's realcreated_at(D2). Giza obeys this value, on both sides. A rumor that already carries anexpirationkeeps it and gets no second one. Today that is only a confederation statement. A second tag would get the statement refused:ConfederationStatementsreads its tags withsingleOrNull, and twoexpirationtags read as none. - Wrap:
["expiration", wrap.created_at + (rumorExpiration - rumor.created_at) + 2 days]. This is quartz's own formula (GiftWrapEvent.build'sexpirationDelta). The wrap'screated_atis already pushed up to two days into the past so that a relay cannot see when a message was really sent, and the formula carries that same random offset into the expiry. The result is the rumor's expiry plus a random[0, 2 days]. A wrap expiry of exactlycreated_at + 86400would give the send time away again. The offset only ever moves the expiry later, so a relay never drops a wrap before the sender meant it to. The cost is that the ciphertext can sit on the relay for up to two extra days. When the rumor has no expiration (a person's message with the policy Off), the wrap has none either. - Seal: no tag. Phase 0 found that quartz does tag the seal. Giza still does not, for three
reasons. NIP-59 says seal tags MUST be empty. Giza's own
GroupDmRefusalrefuses a group's seal with any tag, andInboxRefusalrefuses an inbox seal with more than one. And quartz'sRumor.mergeWith, which Giza's receive path uses, appends the seal's tags to the rumor's. So a tagged seal would put a secondexpirationon every rumor Giza receives. - The sender's own copy is kept and given the same rumor expiry. A second device of the sender's can then read the sender's half of the conversation for as long as the recipient can. It also lets that device join a ceremony that a first device started. NIP-17's other option, sending no self-copy, would silently break both.
The randomness comes from the wrap's own created_at, so tests control it by passing that value
in.
D6. Deleting locally is the feature, and protocol payloads wait for their session
The relay part is best effort. What a person actually experiences is their own device deleting the message, so:
- What a person wrote is deleted at the rumor's expiration, on both sides. The deletion is a
hard delete of the
ChatMessagerow and everything that holds its words: theGiftWrapPayload, theGiftWrapSeal, the wrap'sNostrEventandGiftWrapMessage, the broadcast-request relation rows, and any notification-ledger entry that stores message text. A soft delete would leave the words on disk, which defeats the point. - A protocol payload is deleted at the later of its expiration and its release. "Released"
means the session it belongs to has finished: completed, failed or abandoned. A
PayloadRetentionhook per protocol answers that question (Phase 5). Until then the rows stay, because the manager rebuilds the session from them. When the payload goes, any chat line it rendered ("Alice proposed signing…") goes with it. The session's own record, and whatever the session produced, stays. - A message that has already expired when it arrives is not filed and does not notify. This is NIP-40's "ignore expired events". It can happen because the wrap outlives the rumor on the relay (D5), and because re-syncs happen. An expired protocol round that arrives late is ignored the same way. Its session either had what it needed already, or a resend brings a fresh copy.
- A wrap that has been deleted is not decrypted again. A small
ExpiredGiftWrap(id, dropAfter)tombstone remembers wraps that were already handled until the wrap's own expiration has passed. Without it, every sync would download the jittered wrap again, decrypt it, find it expired, and throw it away. The outbound side needs no tombstone.FrostSigningManager.isQueuedonly stops a re-published round from overwriting a row that is still stored, and once a swept row has gone there is nothing for it to overwrite. - Expirations from other people are obeyed whatever this device's own setting is. A message that a Bennu user sent with a one-hour expiry disappears after an hour.
- A reply that quotes a deleted message shows "This message has disappeared" in place of the quote. It never shows the quoted text, which would be a second copy.
- An OS notification showing a message's text is cancelled when that message is deleted.
D7. Honest about what it is
The settings screen and the conversation say what the feature does, and nothing more:
Messages you send are deleted from your devices and from the recipient's Giza after this time, and relays are asked to delete them too. Other apps, screenshots and relays that ignore the request can keep a copy.
And, under the list of lengths:
Signing and key-ceremony messages always expire. They are kept for at least a day, or a week for key ceremonies, and are not deleted from this device until the ceremony they belong to has finished.
The description also says what happens if the recipient is offline for longer than the chosen time: the relay may drop the message before the recipient ever downloads it. That consequence is real, and the default makes it more likely, so people should be told about it.
D8. The relay has to support NIP-40, and Phase 0 checks that it does
NIP-40 says clients "SHOULD NOT send expiration events to relays that do not support this NIP".
Giza sends every NIP-17 wrap to ephemeral.mantra.press. Phase 0 reads that relay's NIP-11
document. If supported_nips includes 40, nothing more is needed. If it does not, the fix is to
add support on the relay, or to add a second DM relay that supports it. The fix is not to
leave the tag off: the local deletion still works without relay support, and it is the larger
part of the feature. Turning sending to the recipient's 10050 relays back on is outside this
plan's scope. Phase 0 records the finding so that whoever re-enables it filters by
supported_nips.
D9. Existing users get the default from the next message they send
The migration gives every existing identity the one-day default. Messages and rounds sent before the upgrade stay as they were: the policy applies to what is sent after it and is never applied retroactively. A ceremony that is open during the upgrade keeps running. Its earlier rounds have no expiry, its later ones do, and the session does not care which is which. The first time a person opens a NIP-17 conversation after the upgrade, a one-time notice says "New messages you send here disappear after 1 day", with an action that opens the setting. Without that notice, a person's own words would start disappearing when they had changed nothing.
D10. When a group sends, the expiry is part of what its quorum signs
For the two group paths, the rumor goes inside a seal that the group signs in a FROST round. That puts the rumor's expiration inside what the admins sign:
- The proposer's device sets the rumor expiration when it proposes, from the room's override or the proposer's default. The signing review screen shows it, for example "Disappears 1 day after it is sent", so every signer approves the expiry along with the words.
- A signer's device checks that the expiration is within D3's bounds. If it is not, the device refuses the proposal out loud. It does not sign a message that would expire unreasonably early or late. A message the group sends with no expiration is also refused, unless the proposer's policy is Off.
- The device that wraps the message adds the wrap expiration with jitter (D5), as on the one-to-one path.
- Both paths stay behind their existing flags (
groupDirectMessages,groupInbox).
D11. MLS rooms are not covered, and the screen says so
A group's Marmot room already has a group-wide retention that every member's client applies. That is a different model: one value the group agrees on, set through a commit. The settings screen states that the setting covers direct messages and quorum and confederation conversations, and that a group's own room follows the group's setting. Letting a person set the group's retention from Giza is a natural next step. It is a separate plan, because it is an MLS proposal, not a tag.
D12. You can see a message is going to disappear
- The app bar of a NIP-17 conversation shows an hourglass and the current length ("1 day") when a policy is in force. Tapping it opens the conversation's setting.
- An expiring message has a small hourglass next to its time. Its
contentDescriptiongives the time left, because the icon carries information the text beside it does not. - When an incoming message's expiry differs from the conversation's setting (D1), nothing extra is shown. The hourglass already says that the message will go.
- Protocol lines get no hourglass. They always expire, so a marker on every one would carry no information.
Phases
Phase 0: this document, and nine checks
- quartz. Does quartz's NIP-17 builder (
NIP17Factoryor its successor) putexpirationon the seal, the wrap, or both? DoesSealEventreject a seal with tags? This decides the seal question in D5. - The relay. Fetch
ephemeral.mantra.press's NIP-11 document and look for 40 insupported_nips. Also publish an already-expired test event and confirm the relay refuses it (D8). - Bennu. Check that a Bennu build accepts an
expirationtag on a kind 14 rumor and on every protocol rumor. A Bennu device that refuses a DKG round it does not recognise would stall every mixed Giza–Bennu ceremony. This needs a test, not an assumption. - The kinds. List every
kindwritten toGiftWrapPayloadtoday, from the code and from a real database. Each one gets a class in D2's table. - The floors. For each protocol in D2's table, find how long a real session stays open: from the code's timeouts and from the device runs in the protocol's own document. Raise a floor that is too short.
- Readers of the payload table. Confirm that
ChillDkgRitualManager,ConfederationRitualManagerandFrostSigningManagerare the only code that reads protocol payloads back fromGiftWrapPayload. For each one, find the session state that says "finished". For confederation statements, find out whether the confederation's status is derived from the statements each time it is read. If it is, deleting them erases a formed confederation, and Phase 5 has to store the status first. - Where words are stored. Check the notification ledger, any search or full-text index,
draft storage, reply previews and the logs (
sealGiftWrapPayloadlogs the rumor JSON at debug level). Each place found gets a deletion step in Phase 4, or the log line is removed. - Participants. Confirm that every NIP-17 room includes the local user as a participant, so that the sender's copy really is sealed (D5).
- The Welcome. Read MIP-02 for anything it says about a Welcome's lifetime or expiration, and adjust its floor to match.
Done when: each check's answer is written under this phase, and D2, D5 and D8 are updated if an answer changes them.
Done, 2026-11-22. The checks were run against quartz 2.20.1 and marmot-kmp 2.3.0 from the
Magpie mirror, against the relay itself, and against Bennu's bennu-kmp at 2db6dde5.
- quartz tags all three layers. The rumor carries the expiry.
SealEvent.buildandGiftWrapEvent.buildeach addcreated_at + delta + 2 days, wheredeltais the rumor's expiry minus itscreated_at.SealEventdoes not refuse a tagged seal.Rumor.mergeWithappends the seal's tags to the rumor's when it unseals, andGiftWrapSeal.decryptGiftWrapPayloadunseals that way. D5 now uses quartz's wrap formula and keeps the seal empty, for the reasons given there. - The relay.
ephemeral.mantra.presslists 40 insupported_nips, so D8 needs nothing more. It also describes itself asnak serve, "a local relay for testing, debugging and development". Phase 8's relay check should keep that in mind. - Bennu reads rumor tags by name. It has no check on the number of tags, or on unknown tags,
anywhere in
composeApp. An extraexpirationon the rumor is safe there. Bennu has no group DM or inbox refusals, so the seal question does not reach it. - The kinds. Five producers write
GiftWrapPayload:sendChatMessage(14, plus whatevermessageTypea caller passes),ChillDkgRitualManager(its ritual kinds),FrostSigningManager(the signing kinds, and any kind its queue is handed),ConfederationRitualManager(the confederation DKG kinds) andMarmotOutboundDao.deliveryWelcome(444). Every one of them hashes the rumor id from its tags itself, so each one has to stamp before it hashes (Phase 3). - The floors. No ceremony has a timeout in code. A DKG, signing or confederation ceremony stays open until it completes, fails or is abandoned. The floors in D2 stand.
- Readers of the payload table.
ChillDkgRitualManager(around line 610),ConfederationRitualManager(around line 603) andFrostSigningManager(around line 869) are the only readers.ShareRefreshManager,InboxKeyRitualManager,ConfederationSigningManagerandChronicleManagerreadMarmotInnerEventonly, which is out of scope. Confederation statements do not travel on this path at all. They go through the group inbox (GroupInboxManager,InboxReplies), so the question of the confederation's stored status moves to Phase 7. - Where words are stored.
NotificationLedgerstores a cursor and switches, but no text. There is no full-text index and no draft table.ChatMessagehas foreign keys toGiftWrapPayloadwithON DELETE CASCADE, so deleting a payload deletes its chat line. The debug log of the rumor JSON insealGiftWrapPayloadis real, and Phase 3 removes it. - Participants.
createNip17ChatRoomputs the local user in the room, andpersistInboundChatMessagealready discards "our own message coming back". The self-copy is sealed. - The Welcome. marmot-kmp's own
WelcomeGiftWrapsets no expiration, and its sources say nothing about a Welcome's lifetime. The seven-day floor stands.
Phase 1: pin today's behaviour, and the pure core
- Tests that pin today: a payload sealed by
sealGiftWrapPayloadhas noexpirationon any layer, and a confederation statement's existingexpirationtag comes through unchanged. - New
nostr/DisappearingMessages.kt, pure functions only, with no database (the same pattern asMarmotDirectMessage):MIN_SECONDS,MAX_SECONDS,DEFAULT_SECONDS = 86_400,PRESETSclassOf(kind): ExpiryClass, which isWrittenorProtocol(floorSeconds), withUNCLASSIFIED_FLOOR = 7 dayspolicyFor(roomOverride: Long?, identityDefault: Long): Long?expiryFor(kind, createdAt, policy, existingTags): Long?. It is null only for aWrittenkind with the policy Off, and it returns the existing tag's value when there is one (D5).wrapExpiration(rumorExpiration, rumorCreatedAt, wrapCreatedAt): LongexpirationOf(tags): Long?
commonTest:- Every kind the app writes to the queue is classified explicitly. The test lists the
ritual
ALLsets, the FROST kinds, the confederation kinds and 444, and fails on any kind that falls through toUNCLASSIFIED_FLOOR. This replaces the allowlist test from the first draft. - Protocol kinds expire even with the policy Off, at their floor.
- The bounds, Off versus
null, the jitter staying within[0, 2 days]and never moving earlier, and a malformed tag (non-numeric, or beforecreated_at) parsing as "no expiration".
- Every kind the app writes to the queue is classified explicitly. The test lists the
ritual
Phase 2: storage
Migration 49 → 50, following the pattern in database/migrations/:
ChatRoom.disappearingMessageSecs: Long?ChatMessage.expiresAt: Instant?, with an index so the sweeper's "next to expire" query is cheapGiftWrapPayload.expiresAt: Instant?, so the sweeper can find protocol payloads without parsing tags- New table
ExpiredGiftWrap(id PRIMARY KEY, dropAfter), for wrap ids inbound and payload ids outbound (D6) - In the aux database: the identity default, stored next to (or as a column of)
NotificationLedger, with existing rows set to 86 400 (D9). ADisappearingSettingsStorehas the same shape asNotificationSettingsStore. ChatRoom.disappearingNoticeShownAt: Instant?for D9's one-time notice
Tests: a migration JVM test in the style of ReadMarkMigrationJvmTest, run against a version-49
database with NIP-17 and MLS rooms in it.
Built. AutoMigration(from = 49, to = 50), with no spec, because nothing moves. It differs from
the plan in two ways:
- The identity's default is a table of its own,
DisappearingSetting(userPublicKey, defaultSeconds), not a column ofNotificationLedger. A ledger row exists only once notifications are armed, and a policy has to apply before that. A missing row reads as one day, so D9's upgrade needs no data step. ExpiredGiftWrapholds inbound wrap ids only (D6 dropped the outbound tombstone).GiftWrapMessagegainsgiftWrapPayloadIdandexpiresAt, which the plan did not have. The cascade runs wrap → seal → payload → chat line, so deleting a wrap early would delete an unfinished ceremony's round with it. The sender's one-per-recipient wraps also had no link to their payload at all, only the first seal did. The sweeper needs both columns (Phase 4).GiftWrapPayload.expiresAtdefaults to the value read off the row's own tags. Every producer and the inbound path therefore record it without being changed.
DisappearingDao and DisappearingSettingsStore sit beside them. DisappearingMessagesMigrationJvmTest
covers the upgrade, the store and the tombstones, and ShippedProfileUpgradeJvmTest now expects
version 50.
Found while building, and Phase 4 has to handle it: ChatRoom.initialGiftWrapPayloadId is a
foreign key to GiftWrapPayload with ON DELETE CASCADE. NostrDao sets it to the payload that
first created a NIP-17 room on this device. Deleting that payload would delete the whole
conversation. The sweeper clears the reference before it deletes the payload.
Phase 3: sending, for every kind
- One place applies the policy. A single
DisappearingMessages.stamp(payload, room, identityDefault)runs before everyGiftWrapPayloadis written. It appends the rumor expiration to the tags, before the payload id is hashed, so the payload id is the id of the rumor the recipient will see. It also setsGiftWrapPayload.expiresAt. The callers aresendChatMessage,ChillDkgRitualManager,FrostSigningManager,ConfederationRitualManagerandMarmotOutboundDao.deliveryWelcome. Each of them hashes its own id today, so each one moves to callingstampfirst. A JVM test inserts a payload through each caller and asserts that it has an expiration. That test is what stops a sixth caller from skipping it. sendChatMessagealso writesChatMessage.expiresAt.sealGiftWrapPayloadreadsexpirationOf(giftWrapPayload.tags). When it finds one, it adds the jittered expiration to the wrap's tags. The seal is left alone (D5, after Phase 0). The rumor needs no change, becauseRumorAssembleralready copies the payload's tags.persistAndBroadcastGiftWrapsetsNostrEvent.expiresAtfrom the wrap. The existingNostrEventDaopredicate (expiresAt IS NULL OR expiresAt > :now) then covers it with no further change.- A message whose rumor expired before it was sent (the device was offline for longer than the policy) is not sealed and not broadcast. For a person's message, the sweeper deletes its chat message like any other, and a snackbar tells the person: "1 message expired before it could be sent". For a protocol round, the round is dropped and its manager is told, so the session can re-propose or fail out loud rather than wait for nothing. Sending either one late would publish something its own tag says should already be gone.
- The
sealGiftWrapPayloaddebug log of the rumor JSON is removed (Phase 0, check 7).
Tests (JVM, in NostrNip17DaoJvmTest or a new DisappearingSendJvmTest): every combination of
room override and default; protocol kinds at their floor, including with the policy Off; a
confederation statement keeping its single tag; the payload id equal to the rumor's id; wrap and
rumor expirations as D5 describes; the self-copy carrying the same rumor expiry; an expired
queued payload never reaching BroadcastNostrEventRequest.
Built. One store, DisappearingSettingsStore.stamp, does the stamping. sendChatMessage,
ChillDkgRitualManager.broadcast, ConfederationRitualManager.broadcast,
FrostSigningManager.broadcast and MarmotOutboundDao.deliveryWelcome each call it before they
hash. The DKG and FROST producers stamp only on their NIP-17 branch. A Marmot room's rounds follow
the group's retention, as before. FrostSigningManager stamps again on each step of its
same-second id search, because the expiry is worked out from created_at. The wrap's tag uses
quartz's formula, and the seal stays empty. persistAndBroadcastGiftWrap records each wrap's
payload and expiry on its GiftWrapMessage.
It differs from the plan in three ways:
NostrEventhas noexpiresAtcolumn. The predicate the plan relied on is onMarmotGroupEvent. The wrap's row goes when the sweeper deletes its payload.- An expired, unsent payload is left unsealed rather than reported to its manager. The sweeper
deletes it: a person's message at once, a round once its session lets it go. The count of
unsent messages comes back from each sweep (
Swept.unsent). The snackbar for it is left to Phase 6. - The planned test that every producer stamps is covered for
sendChatMessageinDisappearingSendJvmTest. For the protocol producers it is covered by the full suite (1,866 tests) passing with them stamping. There is no per-producer assertion yet.
Phase 4: receiving, and the sweeper
GiftWrapSeal.decryptGiftWrapPayloadcarries the rumor's tags through, as it already does. It setsGiftWrapPayload.expiresAt, andpersistInboundChatMessagesetsChatMessage.expiresAt.- On arrival: if the rumor has already expired, nothing is filed, nothing is notified, no protocol
manager is handed it, and an
ExpiredGiftWraptombstone is written. The NIP-17 receive path checks the tombstone before it decrypts. - The notification classifier skips expired messages, and
NotificationDispatchercancels the OS notification when a message is deleted. - New
managers/DisappearingMessageSweeper:sweep(now)hard-deletes, in one transaction, every expired written message (D6's list) and every expired protocol payload that itsPayloadRetentionhook has released (Phase 5). It returns what it deleted.- It runs at app start, on returning to the foreground (
AppLifecycle), inBackgroundSyncPass, and from a timer set for the nextexpiresAtwhile the app is open. - It prunes tombstones past their
dropAfter. - Until Phase 5 lands, protocol payloads are never released. The sweeper skips them, so shipping Phase 4 alone deletes nothing a ceremony needs.
- Reply previews and quoting read through a lookup that turns a missing message into "This message has disappeared".
Tests: a JVM test of the sweeper for each row type; inbound drop and tombstone; a re-sync of a
tombstoned wrap not decrypting it; another sender's one-hour expiry being obeyed while this
device's setting is Off; the notification not being raised; a protocol payload past its expiry
but not released surviving a sweep. Add a case to NotificationClassifierJvmTest.
Built. DisappearingMessageSweeper.sweep asks a PayloadRetention about each due payload.
Phase 4 ships WrittenOnlyRetention, which releases only what a person wrote. sweepPayload, a
transaction in DisappearingDao, does the deleting in this order:
- It clears any
ChatRoom.initialGiftWrapPayloadIdthat points at the payload. - It deletes every wrap linked to the payload, plus the wrap around its seal for rows filed before the link existed. The cascade takes each wrap's seal with it.
- It deletes the payload, which takes its chat lines with it.
Wraps that have no payload here go at their own expiry. GizaRuntime.disappearing runs the
sweeper. It watches the soonest GiftWrapPayload.expiresAt, wakes when that time comes and every
hour besides, and withdraws any notification that showed a deleted line
(NotificationDispatcher.withdraw). It starts beside notifications: in GizaNavHost, in
StayConnectedService and in the background pass's engines. NotificationPolicy drops an expired
line as Reason.Expired.
It differs from the plan in one way. A message that arrives already expired is not deleted on arrival. The sync that delivered it writes a request row against the event's id straight afterwards, under a foreign key. So the arrival path deletes the seal, which is the part this device could decrypt. It empties the wrap's content and keeps the empty row until the wrap's own expiry, and the unlinked-wrap rule deletes it then. While the row is there, a re-sync finds the event already stored and opens nothing. The tombstone lasts two days longer still, for a relay that serves the wrap after it should have dropped it.
Not needed: the "This message has disappeared" placeholder for a quoted line. In NIP-17 rooms
nothing sets or reads ChatMessage.replyToMessageId or quotedMessageId outside the model, so
no NIP-17 line quotes another. A group's direct messages do have replies, and Phase 7 deals with
those.
Phase 5: protocol payloads, released when their session is done
- A
PayloadRetentioninterface withisReleased(database, payload): Boolean, implemented by each protocol that reads payloads back (Phase 0, check 6):ChillDkgRitualManager: released when the DKG session has completed or failed.FrostSigningManager: released when the signing session has a signature, a failure, or has been abandoned.ConfederationRitualManager: released when the confederation's key ceremony has completed, failed or been abandoned. Its statements are not on this path (Phase 0, check 6).- The Welcome: released once the payload is sealed. Nothing reads a Welcome back.
- Any other kind: released when its expiry passes, which is the same rule as a written message.
- The chat lines that protocol payloads render are deleted with them.
- The sweeper asks the hook for each expired protocol payload, and deletes it once the hook says it is released.
- Tests: for each protocol, an open session keeps its expired payloads, and a finished one loses
them. A DKG run with the policy at its minimum still completes when one admin is offline for
six days. A signing session whose proposal expired off the relay is completed by a resend
(
frost-session-resend.md). A formed confederation still reads as formed after its statements have been swept. InChillDkg…JvmTest,CeremonyFollowThroughJvmTest,ConfederationCeremonyJvmTestandConfederationStatusTest.
Built. It is one ProtocolRetention object, not a hook on each manager. All three answers are
a lookup of the session that a round's session tag names. GizaRuntime.disappearing now runs the
sweeper with it in place of Phase 4's WrittenOnlyRetention.
- A DKG round is released when its
DkgSessionisCOMPLETEorFAILED. A signing round is released when itsFrostSigningSessionis. A confederation-ceremony round is released when itsConfederationCeremonyis no longerisRunning. Abandoning a ceremony ends it asFAILED, so that case is covered too. - A round whose session this device does not have is released at its expiry. Nothing here will read it back, and by the time its floor has passed, any session that was going to be made from it has been.
- A Welcome is released at its expiry. An inbound Welcome is processed the moment it arrives, and
the only thing that refers back to one is the room's
initialGiftWrapPayloadId, which the sweep clears first.
ProtocolRetentionJvmTest covers an open ceremony keeping its expired round, a completed one
losing it while the session's own record stays, a failed signing releasing its nonce, a round with
no session, a Welcome, and a written message.
Not built, and left for the device run (Phase 8): the end-to-end tests that a DKG survives an admin being offline for six days, and that a signing completes through a resend after its proposal has expired off the relay. Both need two devices and a real relay, which the JVM tests do not model. The confederation-status test is moot here, because statements do not travel on this path.
Phase 6: the screens
Every point in CLAUDE.md applies: strings in strings.xml written in sentence case, spacing from
MaterialTheme.spacing, 48dp targets, icon descriptions decided, ScreenStateTransition,
readableContent(), and NavigateBackButton on pushed screens.
- Settings → "Disappearing messages": a new pushed screen and route. It has a radio list of
D3's presets and "Custom…", which opens a dialog with a number field and a unit selector,
checked against the bounds, with an inline error. Below the list are D7's two paragraphs and
D11's note about groups. Saving reports through
rememberNotifier. - Conversation detail (
ChatRoomDetailScreen, NIP-17 rooms only): a "Disappearing messages" row that shows "Default (1 day)", "Off" or a length, and opens the same picker with an extra "Use default" option at the top. - Conversation: the app-bar hourglass (D12), the per-message hourglass, the one-time notice (D9), and the "disappeared" reply placeholder.
- Run
./gradlew :composeApp:m3Auditwith all budgets at zero.
Tests: view-model JVM tests for the picker's validation and for override versus default, plus a string-catalogue entry for every format string this adds.
Built.
DisappearingMessagesScreensits behindDisappearingMessagesRoute(activeUserPublicKey, chatRoomId?). It is reached from the profile screen, next to Notifications, for the default, and from a NIP-17 room's detail screen for that room's override. It shows D3's presets as radio rows, a custom dialog with a number field and a minutes/hours/days segmented row checked against the bounds, and D7's and D11's paragraphs.- The conversation shows
DisappearingTimerAction, an hourglass in the app bar that opens the room's setting, andDisappearingNotice, D9's one-time card. The transcript showsDisappearsIconbeside an expiring line's time, with the time it goes as its description. ChatRoomMessagingScreengets the store through a defaulted parameter that reads the runningGizaRuntime, so neither caller changed. A preview has no runtime and shows none of it.- Lengths read in the largest whole unit ("1 week", "90 minutes").
DisappearingLengthJvmTestcovers that and the custom dialog's bounds. The m3, brand and wallet audits pass at their budgets.
It differs from the plan in three ways:
- The room detail row shows a fixed description, not the current length. That screen reads the room once, so a length shown there would go stale after a change.
- Nothing yet reports a message that expired before it could be sent. The sweeper counts these
(
Swept.unsent), but there is no path from the runtime's sweeper to a screen's snackbar. - The transcript lines a ceremony writes ("abandoned the shared key ceremony" and the like) are
local summaries. They have no
giftWrapPayloadIdand no expiry. So they show no hourglass, as D12 says, but they are also not deleted with their rounds, which is less than D6 says. They hold text the app wrote, not anybody's words.
Phase 7: when a group sends (D10)
GroupDmSenderandInboxReplies: put the rumor expiration in at proposal time, show it on the signing review, refuse out loud a proposal outside the bounds or missing its expiry, and add the jittered wrap expiration when wrapping.- The group's receive paths (
GroupDmReceiverand the inbox's) obey the rumor expiry and use the same sweeper. - Tests in
GroupDmTodayJvmTest,InboxReplyJvmTestandFrostSigningDeclineJvmTest, for the out-of-bounds and missing-expiry refusals.
All of this stays behind groupDirectMessages and groupInbox.
Built.
- Sending.
GroupDmSender.sendstamps the rumor with the proposer's policy before the seals are built.InboxReplies.buildtakes adisappearAfter, andproposepasses the policy. So the expiry is inside what the quorum signs. - Wraps.
GroupDmSender.wrapOwedhands quartz the rumor's lifetime as itsexpirationDelta.InboxReplies.wrapAndOwereads the lifetime from the group's own copy and gives each wrapInboxWrap.wrap's newexpiration. Both follow D5's formula. - Signer checks.
GroupDmRefusalandInboxRefusalrefuse a rumor whose expiry is not a length a person could choose (DisappearingMessages.isAcceptableExpiry), and say so. - Receiving.
GroupDmReceiverandGroupInboxManagerdo not file a message that is already expired. They keep the wrap's ledger row with its words emptied, so a re-sync does not open the message again. - Storage.
GroupDmMessageandGroupInboxMessagegain anexpiresAt, read off theirrumorJson. They went into v50, which has not shipped, so50.jsonwas regenerated rather than adding a v51. - Sweeping.
DisappearingDao.sweepGroupMessagesruns inside every sweep. It deletes the expired messages, empties the words of the wraps that carried them, and drops whatever was still owed to a relay:GroupDmOutbound, andGroupInboxPublicationby signing session. Inbox messages are swept only for written kinds. A confederation's statements are filed byConfederationManager.recordStatement, not as inbox messages, and they keep their ownexpiration(D5). Phase 0's question about the confederation's stored status therefore does not arise.
It differs from the plan in two ways:
- The signer cannot refuse a message that has no expiry, because it cannot know the proposer's policy. Only an expiry outside the bounds is refused.
- The group's signed seals (
GroupSignedEvent) are the signing session's record and are not swept. A seal is ciphertext, but the group's admins can open it.
Tests: DisappearingGroupMessagesJvmTest covers both conversation kinds, the emptied ledger row,
the dropped outbound row, and a statement surviving. DisappearingMessagesTest covers the signer
check and reading an expiry from JSON. The existing group DM and inbox tests pass with the
stamping in place.
Phase 8: the record, and devices
A device run, written up under this phase:
- Giza ↔ Giza with the default: both sides delete the message after a day. Use a shortened custom length for the run, then repeat once with the real default.
- Giza ↔ Bennu: Bennu files the message, and Giza obeys an expiry that Bennu sends.
- Giza ↔ another NIP-17 client: the message is still readable there, and Giza obeys the other client's expiry.
- After the wrap's expiration, query the relay directly and confirm it no longer serves the wrap.
- A second device of the sender: the sender's half is readable there until the expiry.
- Offline longer than the policy, both as sender and as recipient (the Phase 3 snackbar, and D7's warning shown to be accurate).
- A quorum DKG and a signing with the policy at 1 hour and one admin offline overnight. Both finish, the signing through a resend. Afterwards the relay no longer serves their rounds, and the device keeps the shares and the signature.
- A mixed Giza–Bennu quorum running a signing, with expiring rounds.
Then update the status line at the top of this document, note under each phase what was built and
where it differs from the plan, and add a short CLAUDE.md rule: every NIP-17 payload goes
through DisappearingMessages.stamp, and a new kind gets a class in classOf with the reason for
its floor.
Partly done. The record is done: the status line, the notes under each phase, the CLAUDE.md rule ("Everything sent in a NIP-17 wrap expires") and a row in the docs index. The device run has not been done, so none of its eight steps has been seen working on a phone. Two points from the earlier phases bear on it:
- The DM relay describes itself as
nak serve, "a local relay for testing" (Phase 0). Step 4 shows what that relay does, which may not be what a production relay does. - Steps 6 and 7 cover what the JVM tests cannot: a person told that their message expired before it could be sent (not built, Phase 6), and ceremonies finishing across a real expiry.
What this does not do
- It does not stop a recipient, another client or a relay from keeping a copy (D7).
- It does not change messages or rounds that were sent before it shipped (D9).
- It does not apply to Marmot rooms or Marmot direct messages (D11).
- It does not expire what a ceremony produces (keys, shares, signatures, session records). Only the messages that carried the ceremony expire (D2).
Risks
- A ceremony that loses a round. Protocol messages now leave the relay. A key ceremony that outlasts its seven-day floor, or a signing whose resend never happens, ends up waiting for a round that no longer exists. The floors (D2), Phase 0's fifth check and device-run step 7 are the guard. Where there is no resend, as with DKG, the ceremony has to fail out loud when its rounds have expired, never stall quietly.
- Deleting state that is really a record. If anything derives lasting state from protocol payloads each time it is read, sweeping them erases that state. Confederation status is the known suspect. Phase 0's sixth check finds the others, and Phase 5 does not release a protocol until its result is stored.
- Bennu refusing what it now receives. Every protocol rumor gains a tag. A peer that validates tags strictly could stop taking part in mixed groups. Phase 0's third check and device-run step 8 cover this.
- Messages the recipient never receives. A recipient who stays offline longer than the policy may never get the message. The default makes this a normal case rather than a rare one. D7 tells people. Phase 8 measures how often it happens on a real relay.
- A wrong clock. A sender whose clock is behind sends messages that arrive already expired, and D6 drops them. The 5-minute floor (D3) narrows this. It does not remove it. Log a dropped message's lateness, so that a pattern can be seen.
- A deletion that misses a copy. Words stored somewhere the sweeper does not know about would survive. Phase 0's seventh check, and a sweeper test for each table, guard against it. A new table that stores message text should go through the sweeper's review.
Out of scope
- A local "delete what I receive after…" retention (D1).
- Setting a Marmot group's retention from Giza (D11).
- Sending to the recipient's kind 10050 relays (D8).
- A resend for DKG rounds. If Phase 8 shows that the seven-day floor is not enough, that resend is the follow-up, not a longer floor.
Order and size
| Phase | Depends on | Size |
|---|---|---|
| 0 Checks | none | small |
| 1 Pin and pure core | 0 | small |
| 2 Storage | 1 | small |
| 3 Sending, every kind | 2 | medium |
| 4 Receiving and sweeper | 2 | medium |
| 5 Protocol release | 3, 4 | medium to large, depending on Phase 0's sixth check, and the largest risk |
| 6 Screens | 2 (3 and 4 to be useful) | medium |
| 7 Group sends | 3, 4 | medium |
| 8 Record and devices | all | small |
Phases 3 and 4 can be built in parallel once Phase 2 has landed. Phase 6 can start on Phase 2's store at the same time. Phase 3 can ship before Phase 5: protocol rounds then expire on the relay but are never swept on the device, which is safe. The reverse order is not.
Checking the work
./gradlew :composeApp:compileDebugKotlinAndroid :composeApp:jvmTest
./gradlew :composeApp:m3Audit
./gradlew check