Files
mantra-kmp/docs/README.md
Kgothatso Ngako c8c962e4f4 docs: inventory the unreferenced code in the sync and relay stack
Found while building the long-running sync. One item was orphaned by that
change; the rest was already dead and only became visible because the subsystem
was being read closely. Written down rather than deleted because several pieces
are one decision away from being wanted, and those decisions are not the sync
change's to make.

Every claim is "this identifier appears exactly once in composeApp/src, at its
own declaration", with the two things that method cannot see called out: Room
DAO methods are reached through generated code, and Compose entry points can be
invoked without a textual reference. The DAO cluster is flagged as the least
certain for exactly that reason.

Three findings are more than leftovers:

  - RelaysSocketManager.userRelays is a field nothing ever writes. The
    `userRelays` inside observeRelays is a different, shadowing local, so the
    single-argument publishEvent always takes its FALLBACK_RELAYS branch and the
    user's own relay list is never used for publishing. That is a bug wearing
    dead code's clothes, and the fix is to populate the field, not to delete it.

  - NostrPublisherRepository is entirely unreferenced, and it is the only
    consumer of CachingImportRepository.importEvents. RelayPool and
    RelaysSocketManager each take a cachingImportRepository parameter they store
    and never dereference, satisfied by NO_OP_CACHING_IMPORT_REPOSITORY — so the
    whole seam is a parameter passed from nowhere to nothing. Removing the
    publisher lets the interface and both parameters go with it.

  - sendAUTH is unused because NIP-42 is unimplemented, not because it is
    surplus. AuthMessage is parsed and dropped, so a relay answering CLOSED with
    auth-required is retried forever and can never succeed. Deleting sendAUTH
    means deciding against authenticated relays; that is worth doing on purpose
    or not at all. sendCOUNT and CountMessage are a similar matched pair — both
    go or neither, since a CountMessage cannot arrive if nothing sends a COUNT.

isRecommendedRelay on the two request entities is separated out as its own risk
class: never written, never read, but a Room column, so it wants a migration
rather than a delete.

Ends with an order to do it in, cheapest and least risky first.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 16:28:21 +02:00

18 lines
1.3 KiB
Markdown

# mantra docs
Notes on the parts of this app whose behaviour is not recoverable by reading the
code alone — where the reasoning lives in a protocol, a failure mode that is
silent, or a decision that looked arbitrary and was not.
| document | covers |
|---|---|
| [shared-key-ceremony.md](./shared-key-ceremony.md) | ChillDKG over NIP-17: the rounds, the approval gates, the chat transcript, participant ordering |
| [shared-key-derivation.md](./shared-key-derivation.md) | deriving further keys from the group's threshold key with FROST tweaks — why not BIP32, why no chain code, and the one rule that must not be broken |
| [marmot-membership.md](./marmot-membership.md) | how members join an MLS group, and the epoch race that makes a missing member look like a successful invite |
| [long-running-sync.md](./long-running-sync.md) | the chat subscriptions that stay open instead of pulling once per screen — why the request queue could not simply hold one, and how the group filter follows the room list |
| [dead-code.md](./dead-code.md) | code in the sync and relay stack that nothing calls, why each piece is still there, and which of it is a bug rather than a leftover |
Start with the ceremony if you are new to this area; the next two both assume it.
The last two stand alone, and the dead-code inventory reads as a follow-up to the
sync note.