Skip to content

Consolidation step 2 of 8: trackerless-network code moves into the module [androidbuild] [iosbuild]#42

Merged
ptesavol merged 1 commit into
mainfrom
consolidate/c2-trackerless-network
Jul 4, 2026
Merged

Consolidation step 2 of 8: trackerless-network code moves into the module [androidbuild] [iosbuild]#42
ptesavol merged 1 commit into
mainfrom
consolidate/c2-trackerless-network

Conversation

@ptesavol

@ptesavol ptesavol commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Second step of the module consolidation, restructured per your direction: every former header file becomes its own module partition file — one to one, never one merged unit.

The structure

Each of the thirteen public headers of the trackerless-network package is now its own file modules/streamr.trackerlessnetwork-<Name>.cppm, containing a module partition named after it. Each partition carries:

  • only the third-party, standard-library and generated-code includes its own code uses, in its preamble;
  • an import :<Name>; for every dependency it previously expressed as an include of a sibling header (the old include graph becomes the partition import graph — this is why the earlier dependency-cycle work mattered);
  • an import streamr.<package>; for each sibling streamr package it uses;
  • its convenience shorthand declarations, hoisted to file scope, not exported, and written fully qualified (relative namespace names resolve differently at file scope than inside the package namespace);
  • the code itself, in exported namespace blocks. Exporting the declarations directly is required — the language forbids re-exporting module-internal names through using-declarations (verified with the compiler before choosing this design).

The old merged transition file is gone, the primary interface unit re-exports every partition, and the header directory is deleted — the partition files are the source of truth.

A gotcha worth knowing for the remaining packages (found twice here)

A partition must textually include what its own code uses. Two headers had relied on includes inherited transitively from neighboring headers (<string>'s concatenation operator, folly's blockingWait); with imports, entities reached only through another module's preamble are not reliably visible. The compiler catches these immediately and the fix is adding the honest include — an improvement in include hygiene, incidentally.

The linting outcome — better than before

The full code-analysis step now runs on all fifteen module files of this package. The false positives we feared came from the re-export blocks that consolidation eliminates, so coverage is complete with zero suppressions — the selective-disabling permission has not been needed.

Verification

  • Full monorepo build in the release configuration: green.
  • Trackerless-network tests: twelve unit plus one integration, all passing.
  • The proxy client — the direct importer — still passes all fifteen tests.
  • Standalone single-package builds of both packages: green.
  • Package lint: green, covering all module units.
  • Android and iOS builds run via the title keywords.

🤖 Generated with Claude Code

@cursor

cursor Bot commented Jul 4, 2026

Copy link
Copy Markdown

Bugbot is not enabled for this team, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@ptesavol ptesavol force-pushed the consolidate/c2-trackerless-network branch from fde4ad3 to 3a71303 Compare July 4, 2026 10:21
@cursor

cursor Bot commented Jul 4, 2026

Copy link
Copy Markdown

Bugbot is not enabled for this team, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

Second step of the module consolidation: every former public header
becomes its OWN module partition file, keeping the old directory tree
and short file names - include/streamr-trackerless-network/logic/X.hpp
becomes modules/logic/X.cppm (git detects the renames, preserving file
history). The partition files are the source of truth; the include/
tree is deleted.

Each partition contains `export module streamr.trackerlessnetwork:X;`
with:
- only that header's third-party/std/generated includes in its global
  module fragment,
- `import :Dep;` for the old intra-package include edges,
- `import streamr.<pkg>;` for sibling streamr packages,
- the header's convenience using-declarations hoisted to non-exported
  file scope (fully qualified - relative namespace names resolve
  differently at file scope), and
- the code in `export namespace` blocks (export-using of
  module-linkage entities is ill-formed, verified empirically).

The transition-stage :all partition is deleted; the primary interface
unit re-exports every partition.

Gotcha (hit twice): a partition must textually include what its own
code uses. The former headers received <string>'s operator+ and
folly::coro::blockingWait transitively from neighboring headers;
entities reached only through an imported module's global module
fragment are not reliably reachable.

Also: ProxyClientTsIntegrationTest.cpp (the last file textually
including a package header) now imports, with module scanning and the
direct links imports require; lint.sh runs clangd-tidy on all module
units (full analysis coverage, zero suppressions - the consolidated
units have no export-using re-export blocks, which caused the earlier
clangd false positives).

Verified: full Release build; tn tests 12 unit + 1 integration;
proxy client (importer) 15/15; standalone builds of both packages;
package lint green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ptesavol ptesavol force-pushed the consolidate/c2-trackerless-network branch from 3a71303 to 4588f94 Compare July 4, 2026 10:54
@cursor

cursor Bot commented Jul 4, 2026

Copy link
Copy Markdown

Bugbot is not enabled for this team, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@github-actions github-actions Bot added the ci Pull requests that update Continuous Integration build label Jul 4, 2026
@ptesavol ptesavol merged commit 4b480ca into main Jul 4, 2026
6 checks passed
ptesavol added a commit that referenced this pull request Jul 4, 2026
… events to late listeners (#43)

On the outgoing side the connector starts socket I/O inside
createConnection(), but the endpoint's listeners on the returned
PendingConnection are only registered afterwards (addEndpoint ->
changeToConnectingState). When the main thread is descheduled in that
window for longer than one localhost websocket + streamr handshake
round-trip - realistic only on a loaded 2-core CI runner -
onHandshakeCompleted() runs first: it disarms the 15 s connect watchdog
and then emits Connected on a fire-and-forget emitter with zero
listeners. The emission is lost, no timeout remains armed, and the
endpoint sits in the connecting state forever with the lock-request RPC
buffered (the ConnectionLockingTest.CanLockConnections stall on
ubuntu-latest, PR #42 CI).

IPendingConnection now extends ReplayEventEmitter, so a late listener
receives the latest Connected/Disconnected instead of nothing. To make
that airtight across threads, emit() now performs the latest-event
store and the handler snapshot atomically with respect to on() (both
under mEventHandlersMutex): a listener registered concurrently with an
emit gets exactly one of live dispatch or replay, never neither, never
both. This also closes the pre-existing unsynchronized read of
mEventHandlers in createExecutingEmitLoopHandlersMap().

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Pull requests that update Continuous Integration build docs network

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant