mirror of
https://github.com/logos-messaging/nim-chat-poc.git
synced 2026-07-02 22:49:30 +00:00
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.1 KiB
3.1 KiB
Cleanup 05B — Weak types re-evaluation
Follow-up to 05-weak-types.md. Cleanup Agent 05's verdict was "everything justified, only the doc-comment is fixable". Re-examination found one site Agent 05 dismissed too quickly.
Push-back assessment
| Site Agent 05 dismissed | New verdict | Why |
|---|---|---|
cast[pointer](lezGm) at the three call sites |
FIXABLE | Agent 05 framed this as "consequence of the global being pointer". Correct premise, wrong conclusion. The PUBLIC SURFACE of setGroupManagerRef doesn't need to be pointer — it can take the concrete OnchainLEZGroupManager and erase to pointer internally for the lock-protected global. Removes 3 cast[pointer] from caller sites with no semantic change. |
cast[GroupManager](gm) in setRlnIdentity |
FIXABLE | Agent 05 left this alone. The cast was to the base GroupManager type even though every caller stashes an OnchainLEZGroupManager. Narrowing the cast target to the concrete subtype is type-honest and free. |
rlnGroupManager: pointer global itself |
AGREE, keep pointer |
Cross-thread lock-protected global; Nim ref storage there risks GC interference. Agent 05 was right. |
cast[ptr FetchResult](userData) |
AGREE, keep | C-callback userData pattern. |
cast[cstring](allocShared0(...)) |
AGREE, keep | allocShared0 returns pointer; the cstring cast is the typed view. |
pointer in RlnFetchCallback / RlnFetcherFunc (callbackData, fetcherData) |
AGREE, keep | {.cdecl.} callbacks invoked from C. |
Rust *const u8 in lez-rln-ffi/src/lib.rs |
AGREE, keep | C ABI surface. |
Applied
vendor/nwaku/waku/waku_mix/logos_core_client.nim:setGroupManagerRef*(gm: pointer)→setGroupManagerRef*(lezGm: OnchainLEZGroupManager). Internalcast[pointer](lezGm)does the erasure for the cross-thread global.setRlnIdentitycasts back toOnchainLEZGroupManager(the concrete subtype that every caller actually stashes) instead ofGroupManager.- Comment on
rlnGroupManager: pointerupdated accordingly (mentionsOnchainLEZGroupManager).
vendor/nwaku/waku/factory/node_factory.nim: caller dropscast[pointer](lezGm)— passes the ref directly.src/chat/delivery/waku_client.nim: same caller-site cast dropped.- Mirrored into the loose
logos-deliverycheckout (byte-identical).
Builds: both liblogoschat and liblogosdelivery clean.
Local sim: ALL 15 PASS.
Commit SHAs
- vendor/nwaku:
618ce267 - vendor/logos-lez-rln/logos-delivery (loose):
d960a564 - outer logos-chat:
fce56b3
Deferred
- The internal
cast[pointer](lezGm)insidesetGroupManagerRefand thecast[OnchainLEZGroupManager](gm)insidesetRlnIdentityare now the only two casts in this path. Both are mandated by the cross-thread global pattern. Wrapping them in adistinct pointerhandle was considered and rejected: adistinct pointerwould buy zero safety here (single writer + single reader inside the same module, both casts justified by the cross-thread storage contract), while adding a new type that has to be threaded through callers.