Skip to content

Extract libuv ownership primitives into acyclic uv component - #8281

Open
Amaury Chamayou (achamayou) wants to merge 2 commits into
mainfrom
achamayou-bookish-memory
Open

Extract libuv ownership primitives into acyclic uv component#8281
Amaury Chamayou (achamayou) wants to merge 2 commits into
mainfrom
achamayou-bookish-memory

Conversation

@achamayou

Copy link
Copy Markdown
Member

Layer 1 of a native PR stack

This is layer 1 of a stack of PRs working towards #3517 (acyclic source component dependencies). It is based on the branch of #8278 (achamayou-fictional-couscous) and should be reviewed/merged in that order.

Related to #3517 (does not close it — later layers continue this work).

Change

Eliminates the direct source dependency http -> host, caused by src/http/curl.h including src/host/proxy.h, by extracting the generic libuv ownership primitives into a new acyclic source component:

  • Moved close_ptr, proxy_ptr, and with_uv_handle from src/host/proxy.h to a new internal header src/uv/proxy.h, preserving their asynchost namespace and behavior unchanged.
  • Deleted src/host/proxy.h (internal header, no compatibility shim left behind).
  • Updated every in-tree include (src/http/curl.h and the src/host/*.h files that previously included "proxy.h") to include "uv/proxy.h" directly.
  • Added the new uv source component to scripts/source-dependencies.json with no allowed internal CCF dependencies ("uv": []). The http policy is intentionally not added yet, since later stack layers still need to remove its enclave/node edges.

No public API, behavior, or namespace changes; no compatibility forwarding header.

Verification

  • scripts/check-source-dependencies.py: passes, reports no violations; the http -> host edge is gone and the moved code's edges now point only to uv.
  • Full local build (ninja in a fresh RelWithDebInfo build dir): succeeds with no errors.
  • node_connections_test: 2/2 test cases pass.
  • curl_test: 9/15 test cases pass; the 6 failures are pre-existing (verified by checking out the base branch and rebuilding) and unrelated to this change — they fail because the test environment cannot make real outbound HTTP connections.
  • scripts/ci-checks.sh -f: all checks pass (C/C++ format, includes, copyright, ASCII, JSON/prettier, CI test buckets, etc).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The new src/uv/proxy.h is missing required standard headers for used std:: utilities, which can break builds depending on include order.

Pull request overview

This PR introduces a new internal uv source component to host the generic libuv handle-ownership primitives, removing the http -> host source dependency edge by relocating these helpers out of src/host/.

Changes:

  • Added src/uv/proxy.h containing close_ptr, proxy_ptr, and with_uv_handle in the existing asynchost namespace.
  • Updated internal includes (eg, src/http/curl.h and src/host/*.h) to include "uv/proxy.h" instead of the deleted host header.
  • Extended scripts/source-dependencies.json to define the new "uv": [] acyclic component.

Custom instructions used:

  • None (no repository instruction files from .github/copilot-instructions.md or .github/instructions/ were loaded via tools during this review).
File summaries
File Description
src/uv/proxy.h New internal header hosting libuv ownership/closure helpers.
src/http/curl.h Switched include to the new uv header to avoid http -> host.
src/host/udp.h Switched include to uv/proxy.h.
src/host/timer.h Switched include to uv/proxy.h.
src/host/tcp.h Switched include to uv/proxy.h.
src/host/signal.h Switched include to uv/proxy.h.
src/host/every_io.h Switched include to uv/proxy.h.
src/host/before_io.h Switched include to uv/proxy.h.
src/host/after_io.h Switched include to uv/proxy.h.
scripts/source-dependencies.json Added the new uv component with no allowed internal deps.
Review details
  • Files reviewed: 9/10 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/uv/proxy.h

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splitting namespaces across "components" (folders) is going to get really confusing. host contained both all of ccf::asynchost, and bits of the actual cchost top-level entry point. I think if we're moving this, we need to re-namespace it as well. And we should consider moving more of the UV lifetime wrapper stuff (all the headers currently under host/ which this PR touches), if we're creating a distinct "UV wrapper" component, and its safe (dependency-wise) to do so.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, let's re-namespace? I'm deliberately keeping the changes to a minimum as I break the cycles, because expanding the scope has a tendency to make things harder, but happy to try.

Amaury Chamayou (achamayou) added a commit that referenced this pull request Sep 4, 2026
…e/node cycles

Relocate src/http/http_session.h, http2_session.h, and http_rpc_context.h
into src/enclave/, preserving their http:: namespace and type names.
These are internal runtime adapters that bind the HTTP protocol layer to
enclave session/RPC machinery and ccf::RpcContextImpl (in src/node), so
they belonged with their consumers rather than with the protocol-only
http component.

Update all in-tree consumers (rpc_sessions.h, forwarder.h,
jwt_key_auto_refresh.h) to the new paths, and drop the now-unused
http_rpc_context.h include from frontend.h. Make the moved headers
self-contained by including enclave/rpc_handler.h and enclave/rpc_map.h
directly, and updating relative http/ includes to explicit paths.

Clean incidental http -> enclave edges from the remaining protocol
headers: http2_parser.h and http_proc.h no longer include
enclave/session.h and enclave/tls_session.h respectively (unused),
and http_parser.h drops enclave/tls_session.h in favour of a direct
ds/internal_logger.h include for the logging macros it actually uses.

Extend scripts/source-dependencies.json with the http component's
final allowed dependencies (ccf-api, crypto, ds, uv), matching the
acyclic policy already enforced for other components. The dependency
checker confirms no remaining http -> enclave, http -> host, or
http -> node edges.

Layer 2 of the acyclic source components stack, based on #8281.
Refs #3517.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Base automatically changed from achamayou-fictional-couscous to main September 4, 2026 16:39
Move close_ptr, proxy_ptr, and with_uv_handle from src/host/proxy.h to
a new internal header src/uv/proxy.h, preserving the asynchost
namespace and behavior. This removes the direct source dependency
http -> host caused by src/http/curl.h including src/host/proxy.h.
Update all in-tree includes to reference uv/proxy.h directly, and add
the new uv source component to scripts/source-dependencies.json with
no allowed internal CCF dependencies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants