Skip to content

Initial broker design and implementation#880

Merged
wdcui merged 66 commits into
uliteboxfrom
wdcui/ulitebox/broker-design
Jun 17, 2026
Merged

Initial broker design and implementation#880
wdcui merged 66 commits into
uliteboxfrom
wdcui/ulitebox/broker-design

Conversation

@wdcui

@wdcui wdcui commented May 29, 2026

Copy link
Copy Markdown
Member

This PR implements the broker based on a new design and adds the end-to-end implementation for the broker to provide the support for non-blocking evenfd.

@wdcui wdcui added discussion Open questions must-not-merge:prototype An experimental/proof-of-concept PR that must not be merged. expmt:ulitebox uLiteBox experiment labels May 29, 2026
@wdcui wdcui force-pushed the wdcui/ulitebox/broker-design branch 2 times, most recently from 8d6f5d2 to bc2c10e Compare June 4, 2026 17:25
@wdcui wdcui changed the title broker design/poc Initial broker design and implementation Jun 5, 2026
@wdcui wdcui force-pushed the wdcui/ulitebox/broker-design branch from c889ab4 to 56fe76c Compare June 5, 2026 23:24
@wdcui wdcui marked this pull request as ready for review June 5, 2026 23:24
@wdcui wdcui requested a review from jaybosamiya-ms June 5, 2026 23:25
@wdcui wdcui removed discussion Open questions must-not-merge:prototype An experimental/proof-of-concept PR that must not be merged. labels Jun 8, 2026

@jaybosamiya-ms jaybosamiya-ms left a comment

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.

Bunch of comments all throughout the place about lower-level details. As discussed IRL, the plan is to merge this almost as-is (modulo removing the docs/ dir); a lot of the other comments are mostly to be read right now, but not really change the PR; future PRs will be doing the necessary cleanup. As a 1st order approximation, this current PR is directionally correct, but the agents have left a bunch of code smells that we do need to clean up to keep the project healthy; that's what most of the suggestions are focusing on.

On major bit (other than the docs/) that we should try to remove from this PR before merging, if possible, is the readv/writev changes that are mostly irrelevant to this PR at least as I understand it.

If one of my comments mentions just adding a tiny TODO or such trivially tweaked thing, might be good to just resolve that up front rn; but anything more significant than that probably should go into its own PR.

I'm making a tracking issue for the changes needed btw (#911)

Comment on lines +22 to +35
pub use channel::{
HostControlChannel, LocalControlChannel, PeerCredential, ReceivedBrokerRequest,
ReceivedBrokerResponse,
};
pub use error::ErrorCode;
pub use event::{
AddEventRequest, AddEventResponse, ConsumeEventRequest, ConsumeEventResponse,
CreateEventRequest, CreateEventResponse, EventConsumeMode, EventConsumption, ReadinessState,
WaitEventRequest, WaitEventResponse, WaitOutcome,
};
pub use message::{
BrokerRequest, BrokerResponse, CoreRequest, CoreResponse, EventRequest, EventResponse,
};
pub use object::{ObjectHandle, ObjectReferenceGeneration, ObjectReferenceId};

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.

A large number of pub use make it difficult to follow things along, basically a bunch of modularity gets lost if everything is re-exposed publicly

Comment thread litebox_broker_protocol/src/lib.rs
Comment thread litebox_broker_protocol/src/lib.rs
Comment on lines +10 to +47
/// Broker request sent over the control channel.
///
/// The outer broker request is intentionally small. Object-family and
/// domain-specific operations are grouped below it so new object families do not
/// accumulate as unrelated top-level broker variants.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum BrokerRequest {
/// Protocol negotiation request.
Negotiate {
/// Required protocol version.
protocol_version: ProtocolVersion,
},
/// BrokerCore authority request.
Core(CoreRequest),
}

/// Request adapted by the broker host into a BrokerCore domain call.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum CoreRequest {
/// Event object request family.
Event(EventRequest),
}

/// Broker-owned event object request.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum EventRequest {
/// Create a broker-owned event object.
Create(CreateEventRequest),
/// Check whether an event wait would complete now.
Wait(WaitEventRequest),
/// Add readiness credits to an event.
Add(AddEventRequest),
/// Consume readiness credits from an event.
Consume(ConsumeEventRequest),
}

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.

I'm not immediately seeing the benefits of this 3 layer indirection

Comment on lines +5 to +8
use crate::{
AddEventRequest, AddEventResponse, ConsumeEventRequest, ConsumeEventResponse,
CreateEventRequest, CreateEventResponse, ErrorCode, WaitEventRequest, WaitEventResponse,
};

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.

this is the sort of stuff that becomes unreadable / unfollowable when the crate top becomes pub use everything

agents really prefer making everything pub and everything just into a big top level thing, we need to steer them away from that :)

Comment on lines +484 to +486
// Broker control-channel I/O runs through a host Unix socket in the
// current POC. The transport refreshes read/write timeouts around
// each request.

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.

This seems like an unnecessary weakening of our seccomp filters. I'm not quite sure why read/write timeouts are needed if the broker is healthy

Comment thread litebox_shim_linux/src/syscalls/file.rs Outdated
Comment thread litebox_shim_linux/src/syscalls/file.rs Outdated
Comment thread litebox_shim_linux/src/syscalls/file.rs Outdated
Comment thread litebox_shim_linux/src/syscalls/file.rs
@wdcui wdcui force-pushed the wdcui/ulitebox/broker-design branch 2 times, most recently from 154dda9 to 0f9601c Compare June 17, 2026 20:25
wdcui and others added 15 commits June 17, 2026 13:27
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Introduce modular broker protocol, transport, wire codec, client, core, server, and Unix socket implementation for the initial broker-owned event object path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Track effective protocol negotiation in client and server state, expose version mismatch responses for downgrade retries, and make public broker interface enums forward-compatible.

Map future core outcomes to an Internal protocol error and keep wire tag details contained in the wire layer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Expose broker handles as reference capabilities containing only reference ID and reference generation. Keep object IDs internal to BrokerCore and remove ObjectGeneration from the protocol, wire codec, and server adapters.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Exclude litebox_broker_unix_socket from the confirm_no_std sweep because it is the concrete hosted Unix-domain-socket transport and broker executable for the split-broker POC.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename the broker transport boundary to a channel boundary and tighten the protocol/channel naming so future IPC implementations can share the same semantic broker contract.

Document the protocol, channel, wire, and core separation, including the future notification lane and kernel broker relationship.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep server, core, and Unix socket tests focused on distinct interface and security behavior while removing redundant private implementation coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Separate the Unix socket channel adapter from the hosted userland broker deployment, replace the redundant broker connection wrapper with associations, and align broker interface naming.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
wdcui and others added 22 commits June 17, 2026 13:27
Restore shim-local nonblocking eventfd behavior when no broker control channel is configured, while still using broker-backed counters when available. Update the ratchet and missing test C-file copyright header.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove redundant timeout and deadline transport tests while keeping framing coverage and a single wall-clock partial-frame timeout case.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Simplify the userland broker entry point, move core-request envelope handling into broker-local/LiteBox layers, and keep the Linux runner focused on endpoint setup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cover poll readiness transitions and nonblocking counter saturation in the broker-backed eventfd runner fixture.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Count event requests observed by the test broker so the broker-backed eventfd integration test proves eventfd operations used the broker.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Enable broker-backed event counters to support blocking waits so eventfd status flags can clear nonblocking mode. Special-case pipe and socket readv to perform one backend read, and coalesce small pipe writev calls to preserve PIPE_BUF atomicity.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the spawned eventfd writer handle and join it after epoll_wait so Windows test processes do not remain alive after the test body reports success.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The docs now live on wdcui/ulitebox/broker-design-docs. Drop them from the implementation branch so the PR contains only code changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep eventfd-specific readv/writev handling while routing pipes and sockets through the existing generic fallback paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use plain read/write in the eventfd fixture and remove eventfd-specific readv/writev shim handling that is not needed for the broker POC.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@wdcui wdcui force-pushed the wdcui/ulitebox/broker-design branch from 0f9601c to e1d7407 Compare June 17, 2026 20:27
@wdcui wdcui enabled auto-merge June 17, 2026 20:28
@github-actions

Copy link
Copy Markdown

🤖 SemverChecks 🤖 ⚠️ Potential breaking API changes detected ⚠️

Click for details
--- failure constructible_struct_adds_field: externally-constructible struct adds field ---

Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.48.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field CliArgs.broker_socket in /home/runner/work/litebox/litebox/litebox_runner_linux_userland/src/lib.rs:90

@wdcui wdcui added this pull request to the merge queue Jun 17, 2026
Merged via the queue into ulitebox with commit e91d236 Jun 17, 2026
7 checks passed
@wdcui wdcui deleted the wdcui/ulitebox/broker-design branch June 17, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

expmt:ulitebox uLiteBox experiment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants