Reports for each of the 8 cleanup agents (DRY, types, unused, cycles, weak-types, try/except, legacy, slop) recording verdicts + applied changes + deferred items, plus the consolidated SUMMARY.md. End-of-pass local sim ALL 15 PASSED.
3.9 KiB
Cleanup 01 — DRY (post-squash, 2026-05-28)
Research notes
Re-scanned in-scope Nim files after the May 28 squash (29c64b3 etc.):
src/chat/delivery/waku_client.nimvendor/nwaku/waku/factory/node_factory.nim(mirrored in loosevendor/logos-lez-rln/logos-delivery/and canonicalvendor/logos-lez-rln/logos-delivery-module/vendor/logos-delivery/)vendor/nwaku/waku/waku_mix/logos_core_client.nim(same three-way mirror)vendor/nwaku/waku/waku_rln_relay/rln_gifter/{client,protocol,rpc,rpc_codec}.nim
Cross-checked all three mirror trees — byte-identical pre- and post-edit.
Findings still standing from the prior (pre-squash) pass:
watchMembershipConfirmationhelper inrln_gifter/client.nim— already extracted; both call sites (mix-node self-reg innode_factory.nimand chat-client cushion inwaku_client.nim) use it. No further work.- Hex-encoding loops — now 3 sites in
node_factory.nim(gifterSubmitOnce, waitForChainCommit, statusHandler), all producing uppercase hex fromseq[byte]. Previous pass deferred this; with a third site added, extraction now meets rule-of-three cleanly. is_member_registeredJSON params — 2 sites, but with different post-processing contracts (rawuint64vsMembershipStatusResponse). The shared prefix is only the param string + parseJson. Not worth a wrapper.callRlnFetcher + parseJsonpatterns — different field shapes per call. No real duplication.- rpc_codec.nim getField sequences — standard protobuf decoder shape, not duplication.
Critical assessment
| Candidate | Verdict | Reason |
|---|---|---|
watchMembershipConfirmation |
DONE in prior pass | Already a single helper in rln_gifter/client.nim. |
| Hex-encoding loops (3 sites) | EXTRACT | Three byte-identical 3-line loops, all uppercase. Natural home is logos_core_client.nim (already houses the matching hexToBytes32 decoder). |
is_member_registered params |
SKIP | 2 sites, distinct return contracts. Wrapping the shared 4-line prefix would still need 2 callers that diverge on parsing — net loss. |
callRlnFetcher + parseJson |
SKIP | Each callsite parses a different schema. No common middle. |
| Gifter rpc_codec getField | SKIP | Protobuf field decode — already minimal. |
Recommendations
- High confidence: add
bytesToHexUpper*tologos_core_client.nim, replace 3 hex loops innode_factory.nim. Done. - Deferred: none worth pursuing.
Applied
Added proc bytesToHexUpper*(bytes: openArray[byte]): string (8 lines incl. doc-comment) to vendor/nwaku/waku/waku_mix/logos_core_client.nim, placed adjacent to the existing hexToBytes32 decoder.
Replaced 3 inline newStringOfCap + for-loop + toHex blocks in vendor/nwaku/waku/factory/node_factory.nim with mix_lez_client.bytesToHexUpper(...) calls. Net change: −12 lines in node_factory.nim, +8 in logos_core_client.nim = −4 lines plus clarity gain (intent visible at call site).
Mirrored byte-for-byte to:
vendor/logos-lez-rln/logos-delivery/waku/...(loose checkout)vendor/logos-lez-rln/logos-delivery-module/vendor/logos-delivery/waku/...(canonical submodule)
Builds: liblogoschat and liblogosdelivery both compile cleanly.
Commit SHAs
vendor/nwaku(feat/sim-rln-gifter-auth):d08083c5vendor/logos-lez-rln/logos-delivery(feat/sim-rln-gifter-auth-debug, loose):9240b8d0vendor/logos-lez-rln/logos-delivery-module/vendor/logos-delivery(feat/sim-rln-gifter-auth-debug, canonical):9240b8d0(same SHA as loose — they share the remote branch; orphaned content-identical commit2e9d59b9discarded by resync)- outer logos-chat (feat/sim-rln-gifter-auth-v2): report-only commit (see git log)
Deferred
is_member_registeredJSON param prefix — divergent post-parse contracts make a wrapper net-neutral at best.callRlnFetcher/parseJsonglue — schemas differ per call.- Watcher proc — already factored in prior pass.