Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2615435
Add a static channel config to the server
dallison Oct 9, 2026
f06c6ae
Add the ASIL client
dallison Oct 9, 2026
3d78953
Map ASIL buffers at open and support split buffers
dallison Oct 9, 2026
bdccd14
Share phaser server encoding between the C++ clients
dallison Oct 10, 2026
e94bdae
Require server_defined publishers on static channels
dallison Oct 12, 2026
9a4d6d5
Merge branch 'main' into asil
dallison Nov 5, 2026
c664b74
Share the shared memory protocol between the C++ clients and send nat…
dallison Nov 5, 2026
f4607fd
Merge branch 'main' into asil
dallison Nov 6, 2026
0fe05c3
Fix the CMake, Linux and Android CI builds
dallison Nov 6, 2026
739909c
Build the test plugins after the phaser headers
dallison Nov 6, 2026
7537a5d
Make static channel types bytes
dallison Nov 7, 2026
136277c
Fix the macOS CMake plugin build and run SplitBufferPluginTest on macOS
dallison Nov 7, 2026
c3e247d
Add an ASIL client stress test
dallison Nov 8, 2026
d5c35c4
Use IEEE CRC32 on x86 and fix asil heap-allocation test under -O2
dallison Nov 9, 2026
7b2245a
Let standard publishers create channels beside a static config
dallison Nov 9, 2026
f5098a1
ASIL client: one 16 KB buffer size for server messages
dallison Nov 9, 2026
ffe9bf9
Correct asil-client.md for the zero-copy protocol and channel creation
dallison Nov 9, 2026
0950b1e
Add General Motors copyright and rename the copyright holder
dallison Nov 9, 2026
55a8be5
Accept protobuf wire format for static and tunnel configs
dallison Nov 9, 2026
6e2de66
Document the wire-format static and tunnel configs
dallison Nov 9, 2026
5ef67e7
Merge branch 'main' into asil
dallison Nov 9, 2026
9ff7cb5
Merge branch 'main' into asil
dallison Nov 23, 2026
bfe7a25
Fix the armhf CMake cross-compile by supplying a host protoc-gen-phaser.
dallison Nov 23, 2026
083d707
Let the ASIL client build for 32-bit ARM.
dallison Nov 23, 2026
3c79a69
Fix 32-bit ARM alignment bugs in BitsetView, Phaser, and wire buffers.
dallison Nov 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .cursor/skills/subspace-builds/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,20 @@ bazel build --config=linux_arm32 //server:subspace_server //client:subspace_clie
bazel test --config=linux_arm32 //common:common_test //client:client_test
```

CMake needs a host `protoc` first. The toolchain file is
`cmake/toolchains/linux-armhf.cmake`. CI runs that cross-compile as the
CMake needs a host `protoc` and `protoc-gen-phaser` first. The toolchain file
is `cmake/toolchains/linux-armhf.cmake`. CI runs that cross-compile as the
`cmake (armhf)` job; `scripts/build-arm32-colima.sh` is the local Colima
equivalent.

```bash
cmake -S . -B build/host-protoc -DCMAKE_BUILD_TYPE=Release
cmake --build build/host-protoc --target protoc --parallel
cmake --build build/host-protoc --target protoc protoc-gen-phaser --parallel

cmake -S . -B build/armhf \
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/linux-armhf.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DPROTOC_EXECUTABLE="$PWD/build/host-protoc/_deps/protobuf-build/protoc"
-DPROTOC_EXECUTABLE="$PWD/build/host-protoc/_deps/protobuf-build/protoc" \
-DPHASER_PLUGIN_EXECUTABLE="$PWD/build/host-protoc/_deps/phaser-build/protoc-gen-phaser"
cmake --build build/armhf --parallel
```

Expand Down Expand Up @@ -98,15 +99,16 @@ Android cross-compile so protobuf versions match:

```bash
cmake -S . -B build/host-protoc -DCMAKE_BUILD_TYPE=Release
cmake --build build/host-protoc --target protoc --parallel
cmake --build build/host-protoc --target protoc protoc-gen-phaser --parallel

cmake -S . -B build/android \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=arm64-v8a \
-DANDROID_PLATFORM=android-28 \
-DANDROID_STL=c++_shared \
-DCMAKE_BUILD_TYPE=Release \
-DPROTOC_EXECUTABLE="$PWD/build/host-protoc/_deps/protobuf-build/protoc"
-DPROTOC_EXECUTABLE="$PWD/build/host-protoc/_deps/protobuf-build/protoc" \
-DPHASER_PLUGIN_EXECUTABLE="$PWD/build/host-protoc/_deps/phaser-build/protoc-gen-phaser"

cmake --build build/android --parallel
```
Expand Down
10 changes: 7 additions & 3 deletions .cursor/skills/subspace-clients/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,15 @@ bazel build //rust_client:subspace_client_rust
bazel test //rust_client:client_test

cmake -S . -B build/cmake-Debug -DCMAKE_BUILD_TYPE=Debug
cmake --build build/cmake-Debug --target subspace_client_rust

cd rust_client && cargo build && cargo test -- --test-threads=1
cmake --build build/cmake-Debug --target subspace_client_rust subspace_server
ctest --test-dir build/cmake-Debug -R rust_client_test --output-on-failure
```

Cargo needs the Phaser bindings from a CMake build. To run it directly, set
`SUBSPACE_PHASER_C_RS` to the generated
`build/cmake-Debug/rust_client/subspace_phaser_c_phaser/subspace_phaser_c.rs` and
`SUBSPACE_PHASER_C_LIB_DIR` to `build/cmake-Debug/rust_client`.

Java/JNI for Android:

```bash
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -482,20 +482,21 @@ jobs:
g++-arm-linux-gnueabihf \
qemu-user

- name: Build a host protoc
- name: Build a host protoc and phaser plugin
run: |
cmake -S . -B build/host-protoc \
-DCMAKE_BUILD_TYPE=Release \
-DSUBSPACE_ASIO_RPC=OFF \
-DSUBSPACE_CO20_RPC=OFF
cmake --build build/host-protoc --target protoc --parallel "$(nproc)"
cmake --build build/host-protoc --target protoc protoc-gen-phaser --parallel "$(nproc)"

- name: Configure the armhf build
run: |
cmake -S . -B build/armhf \
-DCMAKE_TOOLCHAIN_FILE="$PWD/cmake/toolchains/linux-armhf.cmake" \
-DCMAKE_BUILD_TYPE=Release \
-DPROTOC_EXECUTABLE="$PWD/build/host-protoc/_deps/protobuf-build/protoc" \
-DPHASER_PLUGIN_EXECUTABLE="$PWD/build/host-protoc/_deps/phaser-build/protoc-gen-phaser" \
-DSUBSPACE_ASIO_RPC=OFF

- name: Build armhf targets
Expand Down Expand Up @@ -530,10 +531,10 @@ jobs:
- name: Set up Android NDK
run: echo "ANDROID_NDK_HOME=$ANDROID_NDK_LATEST_HOME" >> $GITHUB_ENV

- name: Build host protoc for cross-compilation
- name: Build host protoc and phaser plugin for cross-compilation
run: |
cmake -S . -B build/host-protoc -DCMAKE_BUILD_TYPE=Release
cmake --build build/host-protoc --target protoc --parallel $(nproc)
cmake --build build/host-protoc --target protoc protoc-gen-phaser --parallel $(nproc)

- name: Configure CMake for Android x86_64
run: |
Expand All @@ -543,7 +544,8 @@ jobs:
-DANDROID_PLATFORM=android-28 \
-DANDROID_STL=c++_shared \
-DCMAKE_BUILD_TYPE=Release \
-DPROTOC_EXECUTABLE="$PWD/build/host-protoc/_deps/protobuf-build/protoc"
-DPROTOC_EXECUTABLE="$PWD/build/host-protoc/_deps/protobuf-build/protoc" \
-DPHASER_PLUGIN_EXECUTABLE="$PWD/build/host-protoc/_deps/phaser-build/protoc-gen-phaser"

- name: Build
run: cmake --build build/android --parallel $(nproc)
Expand Down
58 changes: 58 additions & 0 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,61 @@ cc_library_static {
export_shared_lib_headers: ["libprotobuf-cpp-full"],
rtti: false,
}

// Phaser messages generated from subspace.proto for the ASIL client's server
// connection. They are sent and received in protobuf wire format. As in the
// Bazel phaser_library rule, the plugin writes
// proto/subspace_phaser/<proto path>.phaser.{cc,h}, generating any.proto too,
// and a short proto/subspace.phaser.h header includes the generated one. The
// .cc and .h outputs come from separate genrules so the headers never end up
// in `generated_sources`.
subspace_phaser_cmd = "$(location aprotoc) " +
"--plugin=protoc-gen-phaser=$(location protoc-gen-phaser) " +
"--phaser_out=add_namespace=phaser,package_name=proto," +
"target_name=subspace_phaser,frontend=protobuf:$(genDir) " +
"-Iexternal/subspace -Iexternal/protobuf/src " +
"$(in) external/protobuf/src/google/protobuf/any.proto"

genrule {
name: "libsubspace_phaser_cc",
tools: [
"aprotoc",
"protoc-gen-phaser",
],
cmd: subspace_phaser_cmd,
srcs: ["proto/subspace.proto"],
out: [
"proto/subspace_phaser/proto/subspace.phaser.cc",
"proto/subspace_phaser/google/protobuf/any.phaser.cc",
],
}

genrule {
name: "libsubspace_phaser_h",
tools: [
"aprotoc",
"protoc-gen-phaser",
],
cmd: subspace_phaser_cmd + " && " +
"echo '#pragma once' > $(genDir)/proto/subspace.phaser.h && " +
"echo '#include \"proto/subspace_phaser/proto/subspace.phaser.h\"' " +
">> $(genDir)/proto/subspace.phaser.h",
srcs: ["proto/subspace.proto"],
out: [
"proto/subspace.phaser.h",
"proto/subspace_phaser/proto/subspace.phaser.h",
"proto/subspace_phaser/google/protobuf/any.phaser.h",
],
}

cc_library_static {
name: "libsubspace_phaser",
defaults: ["subspace_defaults"],
generated_sources: ["libsubspace_phaser_cc"],
generated_headers: ["libsubspace_phaser_h"],
export_generated_headers: ["libsubspace_phaser_h"],
cppflags: ["-fno-exceptions"],
rtti: false,
static_libs: ["libphaser_runtime"],
export_static_lib_headers: ["libphaser_runtime"],
}
114 changes: 109 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,117 @@

## Unreleased

- x86 builds with SSE4.2 no longer use the SSE4.2 CRC32 instruction for
message checksums. That instruction computes CRC-32C, not the IEEE 802.3
CRC32 used everywhere else (including the Rust client), so checksums from
such a build did not verify against other builds. x86 now always uses the
IEEE table. ARM hardware CRC32 already used the IEEE polynomial and is
unchanged.

### Static Channel Config
- `subspace_server --channel_config=FILE` reads a `StaticChannelConfig` and
creates its channels and multiplexers before the server accepts clients.
A file ending in `.pb` or `.binpb` is protobuf wire format; any other name
is protobuf text format. `--tunnel_config` uses the same rule. The
configured channels stay when they have no users, and the server defines
their layout. A standard publisher can still create a channel that isn't
configured by specifying its layout, and any subscriber
can subscribe to one. An ASIL publisher cannot: the ASIL client marks its
connection, and the server rejects its publishers on any other channel.
- Publishers on a static channel must set the new `server_defined` option
(`PublisherOptions::SetServerDefined`, `server_defined` in the C, Python,
Rust and ASIL clients) and can't set the slot size, number of slots, fixed
size, checksum size, metadata size, subscriber queue arena size or split
buffer setting. The server rejects `server_defined` on any other channel.
`CreatePublisherResponse` now reports the channel's slot size, checksum
size, metadata size, split buffer setting and fixed size, and a
`server_defined` publisher uses them.
- `subspace_publisher_options_server_defined()` in the C client gives
options for a static channel.
- The default `checksum_size` in the C++ and Rust `PublisherOptions` is now 0,
which means 4 bytes as before, so a `server_defined` publisher can use the
default options.
- A multiplexer with no publishers now reports its slot size.
- Publishers on different virtual channels of a multiplexer are checked
against each other for fixed size and locality, as they share the
multiplexer's buffers. Before, a second fixed-size publisher on another
virtual channel was rejected, so a static multiplexer could only have
publishers on one virtual channel.
- The server creates the message buffers of every static channel and
multiplexer when it starts, so subscribers can map them before any
publisher exists.
- `use_split_buffers` in a static channel or multiplexer config gives it
split buffers, which the server creates.
- `type` in a static channel or multiplexer config is bytes, the same as the
channel type on the wire. A quoted string is that text's bytes, and
protobuf text escapes carry an opaque blob such as ROS metadata or a
protobuf descriptor. A virtual channel still takes its type from its
multiplexer.
- `GetClientBuffersRequest` can ask for one prefix or slot of a split buffer
set with `filter_slot`, `is_prefix` and `slot_id`.

### ASIL Client
- `asil_client/` is a new C++17 client for safety-related software. It
shares channels with the standard clients through the same shared memory
protocol, using only the standard library and
POSIX. It is built without exceptions or RTTI, returns an error code from
every operation, and allocates no memory while publishing or reading.
Checksums, metadata, `ReadNewest`, dropped message counts and activation
messages work with the standard clients. The server handshake is behind a
replaceable `ServerConnection` interface. `PhaserServerConnection`
implements the standard protocol with phaser messages in fixed buffers,
sent and received as the native Phaser payload, so the handshake makes no
heap allocations either. See `docs/asil-client.md`.
- The ASIL client also supports reliable publishers and subscribers, virtual
channels and multiplexer subscribers, subscribers holding up to 64
messages, subscriber queues, split buffers (with C callbacks for slots from
a custom allocator), and the memfd backend. Reading the newest message on
a reliable subscriber marks the skipped messages as read.
- ASIL publishers and subscribers map all of a channel's shared memory when
they open, and publishing and reading make no shared memory calls. A
subscriber needs the channel to have buffers when it opens: always true of
static channels, otherwise a publisher must have opened. Messages in a
buffer that a standard publisher created by resizing after the subscriber
opened return `kBufferNotMapped`.
- The standard C++ client builds its server requests and responses as
phaser messages too, in growable buffers. `ServerWire` in
`common/server_wire.h` encodes them for both C++ clients, with fixed or
growable buffers. The socket carries the native Phaser payload. The Rust
client sends and parses that same payload. Bridge, tunnel, discovery, the
channel directory and statistics stay on protobuf.
- The ASIL client and the standard C++ client share the shared memory
protocol code in `common/`: finding a slot, publishing, the checksum, and
taking, releasing and skipping messages. Sharing it fixed these bugs in the
standard client:
- A reliable subscriber reading the newest message didn't mark the
messages it skipped as seen, so a reliable publisher could no longer get
a slot once the free slots ran out.
- A subscriber ignoring an activation message kept its owner bit on the
slot. If the process then died, the server dropped a reference from
whatever message was in that slot later.
- With retirement notification on, releasing a bridged message crashed if
its slot on the other side of the bridge had a higher id than any slot
in this channel.
- Bazel, CMake and Soong build phaser and generate `subspace_phaser` from
`subspace.proto`. Android CMake cross-compiles need a host
`protoc-gen-phaser` in `PHASER_PLUGIN_EXECUTABLE`.
- CMake also generates the Rust client's Phaser bindings and links their C++
code into the shared library `subspace_phaser_c_rust`, which the Cargo
build links. A Cargo build run outside CMake sets `SUBSPACE_PHASER_C_RS`
and `SUBSPACE_PHASER_C_LIB_DIR` to the files from a CMake build.
- Abseil 20250814.1, protobuf 33.4, cpp_toolbelt 2.1.6 and phaser 3.1.1 in
the Bazel build. CMake uses cpp_toolbelt 2.1.6 and the same phaser. Both
pin phaser 3.1.1 with the CMake build fixes in dallison/phaser#22.

### Subscriber Queues Keep Per-Publisher Order
- A subscriber with an explicit queue size could read a message that had
overflowed its queue after newer messages from the same publisher. The
overflowed message stayed visible in the subscriber's slot bitset, where
bitset recovery and the first read found it. A publisher now clears that bit
when it drops a message from a subscriber's queue, and leaves the entry in
place while the dropped message is still being published. The C++ and Rust
clients both do this, so mixed-language channels keep the same order.
place while the dropped message is still being published. The standard
C++, ASIL and Rust publishers all do this, so mixed-language channels keep
the same order.
- A reliable subscriber's queue no longer drops entries when it is full.
Reliable subscribers read from their bitset, and must never lose a message.
The server sets this when it creates the queue, so upgrade it with the
Expand Down Expand Up @@ -37,9 +140,10 @@
### Tunnel-Compatible Discovery and Bridging
- The server can exchange channels over TCP with peers that use the Cruise
IPC tunnel and discovery protocols. `--tunnel` turns it on, and
`--tunnel_config` names a configuration file in protobuf text format
(`proto/tunnel_config.proto`) that lists the device name, listen port,
peers, discovery denylist and refresh interval. Programs that embed the
`--tunnel_config` names a configuration file, in protobuf text format
unless it ends in `.pb` or `.binpb` (`proto/tunnel_config.proto`) that
lists the device name, listen port, peers, discovery denylist and refresh
interval. Programs that embed the
server call `Server::SetTunnelConfig`. See `docs/tunnel.md`.
- Tunnel discovery uses the Cruise protobuf format on
`/ipc/discovery/proto/receive` (`proto/tunnel_discovery.proto`). ROS-encoded
Expand Down
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,25 @@ FetchContent_MakeAvailable(protobuf)
# Protobuf provides targets like protobuf::libprotobuf and protobuf::protoc
# These targets can be used directly without find_package

# --- External Dependency: phaser (using FetchContent for native CMake) ---
# The C++ clients build their server requests and responses as phaser
# messages: in growable buffers for the standard client and fixed buffers for
# the ASIL client. Phaser uses the Abseil, cpp_toolbelt and protobuf fetched
# above.
# Cross-compiles take a host protoc-gen-phaser in PHASER_PLUGIN_EXECUTABLE.
FetchContent_Declare(
phaser
GIT_REPOSITORY https://github.com/dallison/phaser.git
# phaser 3.1.1 with the CMake build fixes in dallison/phaser#22, plus the
# 32-bit ARM PayloadBuffer header alignment fix from dallison/phaser#23,
# as in the git_override in MODULE.bazel.
GIT_TAG a0c1b24794eff9f872c727664841c4c900da074f
PATCH_COMMAND "${CMAKE_COMMAND}"
"-DPATCH_FILE=${CMAKE_CURRENT_SOURCE_DIR}/patches/phaser_armhf_payload_buffer.patch"
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/apply_patch.cmake"
)
FetchContent_MakeAvailable(phaser)

# --- Option: coroutine/networking backend for the server ---
# Mirrors the Bazel //:coro_backend flag. "co" (default) builds against the co
# coroutine library; "asio" builds the server against Boost.Asio. The value is
Expand Down Expand Up @@ -328,6 +347,7 @@ add_subdirectory(server)
add_subdirectory(plugins)
add_subdirectory(shadow)
add_subdirectory(c_client)
add_subdirectory(asil_client)
add_subdirectory(android)
add_subdirectory(rust_client)
add_subdirectory(rpc)
Expand Down
Loading
Loading