Skip to content

Phase C5: ContentDeliveryManager and the control-layer facade#87

Merged
ptesavol merged 1 commit into
mainfrom
claude/phase-c5
Jul 12, 2026
Merged

Phase C5: ContentDeliveryManager and the control-layer facade#87
ptesavol merged 1 commit into
mainfrom
claude/phase-c5

Conversation

@ptesavol

Copy link
Copy Markdown
Collaborator

Summary

Ports the trackerless-network ContentDeliveryManager and the control-layer facade from the pinned TypeScript (af966cf03, v103.8.0-rc.3), continuing Milestone C of trackerless-network-completion-plan.md.

New modules

  • ContentDeliveryManager — per-stream-part join/leave/broadcast orchestration: builds the layer-1 discovery node, the content-delivery node, the entry-point store manager (PeerDescriptorStoreManager), split avoidance and reconnect for every joined stream part, and the ProxyClient for proxied stream parts. The TS fire-and-forget setImmediate() join runs as a bounded GuardedAsyncScope task on a serial executor.
  • ControlLayerNode — the layer-0 facade (pure virtual). asTransport() stands in nominally for the TS structural extends ITransport.
  • DhtNodeControlLayer — adapter presenting a DhtNode as a ControlLayerNode (mirrors DhtNodeDiscoveryLayer).
  • createStreamPartDiscoveryLayerNode — the TS inline layer-1 DhtNode construction as its own module. The manager takes it as an injected factory (ContentDeliveryManagerOptions::createDiscoveryLayerNode): composing the DhtNode module graph inside ContentDeliveryManager.cppm exhausts clang's per-TU source locations, so the seam is structural. NetworkStack (C6) and the tests supply this factory.

DhtNode

  • Adds deleteDataFromDht(key, waitForCompletion) (TS parity; was still missing).

Source-location relief (enables the new test TU)

23 package modules stop textually including DhtRpc.pb.h/NetworkRpc.pb.h in their global module fragments and rely on the streamr.dht.protos / streamr.trackerlessnetwork.protos module exports instead (the PR #66 pattern), with the std headers each module actually uses spelled out explicitly. Without this, the manager test TU (manager graph + DhtNode + simulator) fails with clang's "ran out of source locations". Generated stubs under modules/gen/ stay textual by design.

Tests

  • ContentDeliveryManagerTest (6 tests, port of the TS integration test): two managers over layer-0 DhtNodes on the simulator — starts, joining, publishing after waiting for neighbors, multi-stream pub/sub, leaving, RTT collection for getNodeInfo. Green in ~2.3 s with clean process exit (no leaked executor keep-alives).

Validation

  • trackerless-network: unit 89/89, integration green, clean exits (unit suite verified in an isolated run; it only tripped when raced against the dht integration suite for cores).
  • dht regression: unit 181/181, integration 43/43, end-to-end 7/7.
  • Package lints and the root lint.sh green. ContentDeliveryManagerTest.cpp joins the documented clangd-tidy std-type false-positive exclusion list (trips inside the generated protobuf setter; the compiler builds and runs it).

Deviations / follow-ups (documented in the module header)

  • TS metrics (MetricsContext/RateMetric) and getDiagnosticInfo not ported (consistent with earlier phases).
  • The TS ConnectionManager private-client mode toggles around proxied-only operation have no C++ counterpart yet — follow-up.
  • Plumtree delivery options are milestone-E scope.
  • ProxyClient::setProxies stays synchronous (shared-library API); the manager calls it directly where TS awaits.
  • The TS proxy e2e tests (proxy-connections.test.ts, proxy-and-full-node.test.ts) are written against the C6 NetworkNode API and move to C6.
  • TS createDiscoveryLayerNode passes periodicallyPingNeighbors/periodicallyPingRingContacts; the C++ DhtNodeOptions lacks these flags — omitted with a comment.

🤖 Generated with Claude Code

Ports packages/trackerless-network/src/ContentDeliveryManager.ts and
src/control-layer/ControlLayerNode.ts (TS pin af966cf03, v103.8.0-rc.3):

- ContentDeliveryManager: per-stream-part join/leave/broadcast
  orchestration; builds the discovery-layer node, content-delivery
  node, entry-point store manager, split avoidance and reconnect per
  joined stream part, and the ProxyClient for proxied stream parts.
  The TS fire-and-forget setImmediate() join runs as a bounded
  GuardedAsyncScope task.
- ControlLayerNode: the layer-0 facade (pure virtual); asTransport()
  replaces the TS structural "extends ITransport".
- DhtNodeControlLayer: adapter presenting a DhtNode as a
  ControlLayerNode (mirrors DhtNodeDiscoveryLayer).
- createStreamPartDiscoveryLayerNode: the TS inline layer-1 DhtNode
  construction as its own module; the manager takes it as an injected
  factory because composing the DhtNode module graph inside
  ContentDeliveryManager.cppm exhausts clang's per-TU source
  locations.
- DhtNode::deleteDataFromDht (was still missing; TS parity).
- Source-location relief across the package: 23 modules stop
  textually including DhtRpc.pb.h/NetworkRpc.pb.h in their global
  module fragments and rely on streamr.dht.protos /
  streamr.trackerlessnetwork.protos imports instead, with the std
  headers they actually use spelled out. Without this the new
  manager test TU cannot compile ("ran out of source locations").
- ContentDeliveryManagerTest: 6 tests over 2 managers on layer-0
  DhtNodes over the simulator (join, pub/sub after neighbors,
  multi-stream, leave, RTT collection in getNodeInfo). Suite exits
  cleanly (no leaked executor keep-alives).
- lint.sh: ContentDeliveryManagerTest.cpp joins the clangd-tidy
  std-type false-positive exclusion list (generated protobuf setter;
  the compiler builds and runs it).

Deviations documented in the module header: TS metrics/diagnostics
not ported (consistent with earlier phases), ConnectionManager
private-client mode is a follow-up, plumtree options are milestone E.
The TS proxy e2e tests target the C6 NetworkNode API and move there.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ptesavol
ptesavol merged commit 78b7a7e into main Jul 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant