Skip to content

Own the Linux runtime layout discovery; ship the GTK main-thread bridge - #274

Merged
turinglambdaai merged 1 commit into
mainfrom
feat/linux-host-reuse
Oct 16, 2026
Merged

turinglambdaai merged 1 commit into
mainfrom
feat/linux-host-reuse

Conversation

@turinglambdaai

Copy link
Copy Markdown
Owner

Closes #246. Closes #247.

Runtime layout discovery (#246)

The staged-vs-packaged layout is Rivet's contract, but its discovery was hand-copied per product (autarx AppModel.swift:255 — an admitted third Swift copy, taskly HostResources.swift, syncpilot discover_runtime_layout, and the Linux host template's own main.cpp). rivet::linux_runtime now owns it (layout.hpp/layout.cpp, part of rivet::platform):

  • discover_layout() locates runtime/*.boot + res/core.zo beside the running executable (/proc/self/exe)
  • discover_layout(stage_root) explicit-root overload for tests and unusual staging
  • RuntimeLayout exposes stage_root, resources, and the four artifact paths
  • layout_error_hint() is the remediation message hosts display verbatim
  • the template main.cpp consumes the library instead of carrying a private copy

macOS parity note: RivetEmbedding already exposes EmbeddedRacketConfiguration.resolvedDefault with the same stage-root logic; docs/embedding.md is the cross-platform pointer. Products migrate by rebasing on the next release and deleting their private copies.

GTK main-thread bridge (#247)

The host template ships src/rpc_bridge.hpp: unpack flattens the generated Result<T> — including the Result<void> specialization Void RPCs produce — into Unpacked<T> (value or error, decided on the reader thread, no exception flow across the hop); post_to_main runs the closure on the GTK main loop, heap-allocated on the reader thread and freed there. The template main.cpp drops its private IntResult/g_idle_add plumbing and shows the pattern end to end. platform/linux/host/README.md documents both under "Runtime layout discovery" and "Completions belong on the main loop".

Verification

  • RivetLayoutTest joins the Linux integration CTest suite (complete/truncated/empty layouts, hint content, executable-path resolution)
  • layout_test.cpp compiled and run locally (non-GTK paths); rpc_bridge.hpp template instantiations (unpack<int> success/error, unpack<void> against the generator's own Result<void> shape) compiled and run locally with glib; main.cpp's GTK link compiles in the Linux CI legs
  • rivet_linux_sources.cmake adds layout.cpp to the rivet::platform library target; downstream hosts link the target and never compile Rivet sources themselves (issue Host integrations must consume released rivet packages, never compile rivet sources into downstream executables #238 contract)

…ridge

The staged-vs-packaged runtime layout is Rivet's contract, but its
discovery code was hand-copied per product (autarx AppModel.swift, taskly
HostResources.swift, syncpilot discover_runtime_layout, and the Linux
host template's main.cpp). rivet::linux_runtime now owns it (issue #246):
discover_layout() locates runtime/*.boot + res/core.zo beside the
running executable, an explicit-root overload serves tests and unusual
staging, layout_error_hint() is the remediation message hosts display
verbatim, and RuntimeLayout exposes stage_root, resources, and the four
artifact paths. The template main.cpp consumes the library instead of
carrying its own copy.

GTK hosts also share one completion-marshaling shape: completions arrive
on the backend reader thread and nothing there may touch GTK objects.
The host template ships rpc_bridge.hpp (issue #247): unpack flattens the
generated Result<T> — including the Result<void> specialization Void
RPCs produce — into an Unpacked<T> decided on the reader thread (no
exception flow across the hop), and post_to_main runs the closure on
the GTK main loop, heap-allocated on the reader thread and freed there.
The template main.cpp drops its private IntResult/g_idle_add plumbing
for the bridge, so a new GTK host starts with the correct pattern
instead of rediscovering thread affinity the hard way.
@turinglambdaai
turinglambdaai merged commit 1f2f796 into main Oct 16, 2026
23 checks passed
@turinglambdaai
turinglambdaai deleted the feat/linux-host-reuse branch October 16, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant