refactor: remove proxy_id concept entirely

Not really needed and just adds extra fluff.
This commit is contained in:
CJ van den Berg 2026-03-10 15:25:20 +01:00
parent e32dc6e9b8
commit bf45b592ac
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
4 changed files with 6 additions and 37 deletions

View file

@ -171,14 +171,10 @@ The defined message types are:
| `"send_named"` | both | `from_id: u64`, `to_name: text`, `payload: cbor` | Deliver to a well-known actor by name |
| `"link"` | both | `local_id: u64`, `remote_id: u64` | Establish a link between a local actor and a remote actor |
| `"exit"` | both | `id: u64`, `reason: text` | Remote actor `id` has exited with reason |
| `"proxy_id"` | both | `name: text`, `id: u64` | Response to `send_named`: here is the opaque ID for this named actor |
| `"transport_error"` | both | `reason: text` | Signal that the sending side is tearing down |
The `from_id` and `to_id` fields are opaque 64-bit integers assigned by the
_home system_ of the actor. ID `0` is reserved and invalid. Named lookups
(`send_named`) trigger the remote side to create or locate a proxy for the
named actor and reply with its assigned ID via `proxy_id`, after which the
sender can use the ID directly.
_home system_ of the actor. ID `0` is reserved and invalid.
---
@ -288,15 +284,9 @@ const Proxy = struct {
### Lifecycle
A proxy is created by the endpoint in two situations:
1. **Inbound message with unknown `from_id`**: The endpoint receives a wire
message from a remote actor ID it has not seen before. It spawns a proxy
for that ID and records it in the proxy table before delivering the message
locally.
2. **Explicit lookup response (`proxy_id`)**: After a `send_named`
exchange, the endpoint now knows the remote ID for a named actor and
creates a proxy for it.
A proxy is created by the endpoint when it receives a wire message from a
remote actor ID it has not seen before. It spawns a proxy for that ID and
records it in the proxy table before delivering the message locally.
A proxy is destroyed when:
@ -424,6 +414,3 @@ unique, which is sufficient for the 1:1 child process model.
- **Backpressure**: The current model has no backpressure - a fast sender
can overwhelm a slow transport. This is acceptable for the initial
implementation but will need attention under load.
- **Named actor re-registration**: If a well-known actor exits and is
restarted under the same name, proxies on the remote side will hold stale
IDs. A generation counter or re-lookup mechanism will be needed.

View file

@ -165,7 +165,7 @@ const Endpoint = struct {
if (self.proxies.get(e.id)) |p|
p.send(.{ "exit", e.reason }) catch {};
},
.proxy_id, .link, .transport_error => return tp.exit_error(error.UnexpectedMessage, null),
.link, .transport_error => return tp.exit_error(error.UnexpectedMessage, null),
}
}

View file

@ -46,14 +46,6 @@ pub fn encode_exit(writer: *std.Io.Writer, id: u64, reason: []const u8) !void {
try cbor.writeValue(writer, reason);
}
/// Encode a `proxy_id` wire message into writer.
pub fn encode_proxy_id(writer: *std.Io.Writer, name: []const u8, id: u64) !void {
try cbor.writeArrayHeader(writer, 3);
try cbor.writeValue(writer, "proxy_id");
try cbor.writeValue(writer, name);
try cbor.writeValue(writer, id);
}
/// Encode a `transport_error` wire message into writer.
pub fn encode_transport_error(writer: *std.Io.Writer, reason: []const u8) !void {
try cbor.writeArrayHeader(writer, 2);
@ -66,7 +58,6 @@ pub const WireMessage = union(enum) {
send_named: SendNamed,
link: Link,
exit: Exit,
proxy_id: ProxyId,
transport_error: TransportError,
pub const Send = struct {
@ -91,11 +82,6 @@ pub const WireMessage = union(enum) {
reason: []const u8,
};
pub const ProxyId = struct {
name: []const u8,
id: u64,
};
pub const TransportError = struct {
reason: []const u8,
};
@ -111,7 +97,6 @@ pub fn decode(frame: []const u8) !WireMessage {
var local_id: u64 = 0;
var remote_id: u64 = 0;
var id: u64 = 0;
var name: []const u8 = "";
var reason: []const u8 = "";
if (try cbor.match(frame, .{ "send", cbor.extract(&from_id), cbor.extract(&to_id), cbor.extract_cbor(&payload) }))
@ -126,9 +111,6 @@ pub fn decode(frame: []const u8) !WireMessage {
if (try cbor.match(frame, .{ "exit", cbor.extract(&id), cbor.extract(&reason) }))
return .{ .exit = .{ .id = id, .reason = reason } };
if (try cbor.match(frame, .{ "proxy_id", cbor.extract(&name), cbor.extract(&id) }))
return .{ .proxy_id = .{ .name = name, .id = id } };
if (try cbor.match(frame, .{ "transport_error", cbor.extract(&reason) }))
return .{ .transport_error = .{ .reason = reason } };

View file

@ -254,7 +254,7 @@ const StdioEndpoint = struct {
else
return tp.exit_error(error.UnknownWireId, null);
},
.link, .exit, .proxy_id, .transport_error => return tp.exit_error(error.UnexpectedMessage, null),
.link, .exit, .transport_error => return tp.exit_error(error.UnexpectedMessage, null),
}
}