Skip to content

rutis v0.12.0

Choose a tag to compare

@github-actions github-actions released this 18 Oct 05:37
· 2490 commits to main since this release
0d2c186

rutis 0.12.0

中文 · 0.11.0 release notes

The main change in 0.12.0 is that services are exposed across languages by themselves: what Node, Bun, Python and Go plugins provide with ctx.provide, and what published Cordis plugins provide, is used by name from other languages, other nodes and Rust with no declaration, and provides becomes optional; Cordis plugins in one Node runtime use each other's services by Cordis's own rules. Next, a Rust application embedding rutis names existing Rust types in its build.rs and leaf plugins call their methods directly, with no HostDispatch written by hand; a Rust service can also tell which row calls it. Third, operating rutis-host: rereading rutis.json while it runs, restarting a crashed local runtime as restart says, and run printing when a runtime ends and comes back. There is also a hook for revoking an identity while running (Rust library). On quality, step three of the plan is done: long soaks, a real network, fuzzing and concurrency models, cross-version combinations and two TLA+ models, with the fixes they found. Plugins of the 0.11 era see one change in behaviour (undeclared services now reach rutis, and on a name clash the row providing it later fails), see "Compatibility" below.

Packages

These packages are all at version 0.12.0:

Registry Packages
crates.io rutis (the kernel), rutis-bridge, rutis-loader, rutis-host; the dylib toolchain rutis-sdk, rutis-dylib, rutis-dylib-meta, rutis-dylib-launcher
npm @arcships/rutis, @arcships/rutis-runtime, @arcships/rutis-bun, @arcships/rutis-host, and the host packages for five platforms
PyPI rutis, rutis-host
Go github.com/arcships/rutis/go/rutis (tag go/rutis/v0.12.0)
GitHub rutis-host binaries for Linux / macOS (x64 / arm64) and Windows (x64), with SHA-256 checksum files

rutis-cli is still released separately.

New

  • The services leaf plugins provide reach rutis by themselves; provides becomes optional (#442, Plugin API): in all four SDKs (Node, Bun, Python, Go), what ctx.provide(name, impl) provides reaches rutis without a declaration, and plugins of other languages use it by name. Its methods are the public methods of the implementation: JavaScript, its own and its prototype chain's functions (not constructor); Python, callable attributes not starting with _; Go, exported methods; all called as async, fields not counting. A provides declaration still applies: it marks methods sync and lets rutis-host check know before running who provides what; existing plugins need no change. An undeclared service appears once its plugin runs, and rows depending on it wait for it as usual; check warns of such a dependency, not failing (it does with --strict). On a name clash the plugin providing it later fails (also when it provides it after loading), naming both: service <name> is already provided by <existing>: row <row> cannot provide it too. A service provided from another thread or goroutine before apply returns has the host handle it before the load completes, and a clash fails the load. The four templates of rutis-host new no longer declare provides, keeping a comment on when to write it. The undeclared services of rows in a dial-in instance (instances of runtimes.remote) are visible only inside that instance (Connect Nodes). The testing tools (@arcships/rutis/testing, the same one under Bun; rutis.testing; Go's rutistest) no longer require a declaration either: service(name) calls by the inferred methods, and the new methods(name) (Go: Service.Methods()) returns the methods rutis sees.
  • Published Cordis plugins use each other's services natively, and theirs reach rutis by themselves (#428, Cordis): Cordis packages mounted from rutis.json (published ones without rutis.provides as well) use each other's services by Cordis's rules within one Node runtime, getting the objects themselves; before, a row depending on another stayed waiting for its services. The services they provide reach rutis without a declaration, used by name by other runtimes, nodes and Rust; the methods are the functions of the service object (its own and its prototype chain's, not constructor), called as async; a package declaring rutis.provides follows its declaration. Name clashes follow the same rule as for leaf plugins. rutis-host check warns warning: <row>: nothing declares <service>; it may be provided at runtime by <rows>, … for a service only such rows may provide, instead of cannot run: nothing provides …, adding ; between Cordis rows of one runtime it resolves in Cordis when the row and one of those rows are Cordis rows. Rust library: rutis-bridge gains row_projection_of, ServiceEvents::announced, Projection::on_announced / service_keyed_occupied / take_refused / on_refused, HostDispatch::provider, RowService::provided_by and RowSchema::announces / cordis; rutis-loader gains Declared::announces and Supply::Announced.
  • Rows use existing Rust services, with no binding written (#440, Embed rutis in a Rust application, exported services reference): an application's build.rs names the types to export, rutis_bridge::build::Exports::new().service("calendar", "calendar_services::Calendar").service_in("notes", "calendar_services::Notes", "session").generate(), a dependency crate's included (its source is found with cargo metadata and read with syn, following re-exports, aliases and #[cfg]; stable Rust). The build generates a dispatcher for each type's public &self methods and TypeScript declarations from the Rust definitions (serde structs and enums as serde writes them, Services, RustError, a <Name>Thrown per error type; they pass tsc --strict); rutis_bridge::include_exports!() declares the module and ServiceCatalog::export_all(exports::all()) registers it: a TypeScript, Python or Go row writes the name in inject and calls the methods, all async. Arguments and results are any serde type (integers beyond ±(2^53−1) as bigints); a function parameter (impl Fn(..) -> BoxFuture<'static, Result<..>>, Arc<dyn Fn ..>) takes the caller's function by reference, the native side going on once its Promise settled and its throw being the native failure; a &Ctx parameter is the calling row's context, so what the method registers there goes with that row; .service_in exports inside each instance of an instanced group. Err(e) is thrown in the caller's language with name (the type), code (the variant), message (Display) and data (the serde value), not as an unclassified call error. A method that cannot be bound is left out with a build warning saying why. Example: examples/rust-services. Rust library: rutis-bridge gains the module exports (Export, ExportPlugin, include_exports!) and, with the new feature exports (which cordis enables), build::Exports; rutis-loader gains ServiceCatalog::export, export_all and share_registered_only.
  • Errors carry code and data (#440, Plugin API): an error thrown in any language can carry a code and data, in the error graph beside name and message: a JavaScript error's string code and data properties, a Python exception's str code and data attributes, a Go error's Code() string and Data() any, Rust's exports::failure. The receiver reads them as code and data (Go: Code, Data; Rust: Error::code(), Error::data()), and they pass on when it throws the error again; data that cannot cross is left out, and the rest of the error still crosses. Python's RemoteError gains the attributes code and data (None when absent), Go's RemoteError the fields Code and Data; Rust's session::Error gains code() and data().
  • A Rust service sees the row that calls it (#441, Embed rutis in a Rust application): Rust library only. During HostDispatch::invoke, rutis_bridge::session::caller_row() returns the calling row as a CallerRow: its id() (the loader's), key() (in its runtime), scope() (the label it isolates the service under, an instance's inside instances), instance() and ctx(). Two rows of one runtime are two callers; an effect registered on ctx() goes when that row unloads or restarts, while the runtime keeps running. A call from Rust, from a peer node or from a runtime outside any row returns None. This works with Node, Bun, Python and Go rows, including 0.11 runtimes: the wire is unchanged; each row has the services it leases in a scope of its own. rutis-bridge gains Process::lease_host_for and HostLease::label.
  • Changing the configuration while it runs (#274, rutis-host): rutis-host run reads rutis.json again on SIGUSR1 on Unix (systemd: ExecReload=/bin/kill -USR1 $MAINPID); with --watch-config (off by default) it does when the file's content changed and stayed the same for 500 milliseconds, the way for Windows and Kubernetes ConfigMaps. All or nothing: the new rows are checked first, and a row failing after the replacement brings the old rows back; a broken configuration leaves the old one running and prints rutis-host: reload rejected: <reason>; nothing changed, an applied one rutis-host: reloaded <file> (<n> rows changed). Rows added, removed and changed apply at once, those of an instanced group in every instance there is; a local runtime removed stops once its rows unloaded. format, id, listen, runtimes.go, runtimes.remote (listen and instances included) and a local runtime added or with changed settings cannot change this way: refused, saying to restart the host. SIGHUP is still a termination signal. Credentials are now read from the environment when a link dials or a far end dials in, so a peer row a reload adds connects too.
  • Restarting a crashed runtime (#274, rutis-host): runtimes.node, runtimes.py and runtimes.bun gain the optional field restart, saying what happens when the runtime's process ends on its own: "no" (the default, as before: its rows wait), "on-failure" (it is started again after a wait and its rows come back; the wait is 1 second, doubling each time up to 30 seconds, back to 1 second after 60 seconds of running, and one more end after 5 restarts within 5 minutes gives up, printing runtime <name>: gave up after 5 restarts within 5 minutes; the numbers are fixed, not configurable), "exit" (the other rows unload and the host exits with the new exit status 3, for its process manager to restart it). dev follows the same rules and defaults, with restart in rutis.dev.json. Go runtimes have no such setting yet.
  • Runtime state lines (#274, rutis-host): rutis-host run and dev print runtime <name>: down (<reason>) when a local runtime's (node, py, bun, Go's go-<binary>) process ends on its own or the runtime cannot start, the reason saying how the process ended, such as runtime py: down (exited with signal: 9 (SIGKILL)); and runtime <name>: running when it runs again. Before, only its rows going back to waiting for its services showed it. Runtimes the host stops (the host stopping, a Go runtime stopping when idle) print nothing. Rust library: rutis-loader gains GoRuntimesHandle::states (each Go runtime's state, without reading the binaries).
  • Revoking an identity at runtime (#273, design): Rust library only, the hook a future management service calls. In rutis-bridge, Revocable::new(inner, revocations) wraps an Identity (static links) or an Admission (access points), and Revocations::revoke(&id) / revoke_all() revokes while everything keeps running: only the connections accepted as that id close (calls in flight on them fail once, as when the network drops), a handshake routed before the revocation is not handed over, and later connections are refused exactly as a wrong token is (403, or close code 4003 for an access point's id), so the dialer waits 30 s as AuthRejected. Other peers, other connections on the same listener and local runtimes are untouched. For an access point with a shared token, revoking an id closes that connection; revoke_all() withdraws the token. Identity and Admission gain revocations(), defaulting to None. rutis-host has no command for it: its tokens come from the environment and cannot be revoked at runtime (Connect Nodes).

Fixes

  • A refused call did not take its call id (#407): when a far end's call was refused while decoding its arguments (failing only that call, the session going on), its call id was not recorded, so the far end sending the same id again had it run as a new call. A refused call now takes its id as a completed one does, and the same id sent again closes the session with invalid or repeated invocation identity.
  • The native generator took a plugin's own type of the same name for a value type (#408): the rutis_plugin generator recognised Instant, BigInt, Bytes, ValueMap and ValueSet by their short names, so a plugin's own type Instant = String was declared as Date. It now resolves types through the source file's uses and full paths and recognises only those rutis-bridge exports; a plugin's own type of that name, or std::time::Instant, is refused with type binding not implemented instead of being declared wrong. Every form that compiles (a short name after use, globs, module prefixes, full paths) is still recognised.
  • NaN and ±Inf in maps and sets became null (#409): the generator's checks looked only at f64 fields and Vecs, so NaN / ±Inf in a ValueMap<String, f64> silently became null through serde. Map keys and values and set elements are now checked at any nesting, refused with the same non-finite number as a struct field.
  • A listening link is registered once applied (#411): a listening link in rutis-bridge used to register on its listener only in the task it starts after being applied. With an access point already on that listener, a static peer dialing in before then was refused as an unknown credential (403), and the dialer waited 30 s as AuthRejected before retrying; now the registration is there once LinkPlugin is applied, and a refused registration (the name taken) is still Stopped. An access point orders connections as they were delivered: of two connections of one id delivered almost together, the later one could before be counted as the earlier.
  • Families registered together were announced as offered twice (#435): Peer::register in rutis-bridge put a family's handler in place and then, under another lock, recorded the number of the offer (since). Another feature registering on another thread in between announced the family already present but without its number, as 0, and only then with its real one. To the far end the family was offered anew: its peer: rows restarted, and one being applied could find PeerRows just withdrawn and stay failed. Only when an end registers two or more families at once (a link that both hosts and imports, say). The number is now put in place together with the handler, so an announcement always carries each family's own.
  • A plugin whose dependency was withdrawn just before its apply stayed failed (#438): when a plugin's dependencies were ready and its apply scheduled, and a dependency was withdrawn before it ran, an apply that read it with require / require_as and returned that read's error as is (require(..)?) left the plugin Failed; provided again by the same provider, the dependency had no new generation, so the plugin was not retried either. A peer: row reading PeerRows could meet this at the moment its host really closed or reopened, and so could Node, Python, Bun and Go rows reading their runtime's service. The kernel now treats that error as it treats InjectUnsatisfied: when this generation's read of the dependency really failed, the plugin waits again and loads when the dependency is back.
  • An embedding application's memory grew as instances were created and closed (#430, found by S7): Projection::attach in rutis-bridge started, for each language row, a task waiting for the runtime's session to end, which lived until then, one per load of a row; Process's table of export slots kept withdrawal records after a row unloaded, one per instance for instance-scoped ids. A multi-tenant application creating and closing tenants over and over grew by about 1.4 KiB a round. The task now ends when the projection closes or is dropped, and the records go with the row.
  • A Python runtime that never exited after its host was kill -9ed (#431, found by S8): when the host was killed and a plugin's cleanup never returned, the Python runtime, at its deadline (RUTIS_SHUTDOWN_TIMEOUT), was to write a line on stderr and exit with 1; its stderr was a pipe to the host, so with the host gone the line could not be written (BrokenPipeError) and the process stayed. It now exits all the same. Unix only: on Windows the runtimes end with the host's Job Object.
  • A Python listen: runtime with its controller connected did not stop on Ctrl-C and skipped its cleanups on SIGTERM (#433, found by S5): on Ctrl-C, python -m rutis listen:… waited, as its event loop closed, for the threads blocked in accept and on the connection, and did not exit; SIGTERM killed the process outright, without running the rows' cleanups. It now does as dial: does: unloads every row, closes the connection and the listener, and exits with 0.
  • A Python listen: runtime printed a traceback when a session ended because the network dropped (#434, Connect Nodes): when the controller's heartbeat timed out or the connection was reset, the node's stderr got the websockets library's log and a full traceback. It now prints one line, rutis: session ended (<reason>); waiting for a controller, for example rutis: session ended (heartbeat timeout); waiting for a controller, and rutis: session ended (replaced by a new connection) when a new connection takes over. A dropped network, a heartbeat timeout or a close by the far end no longer prints websockets' log; other unexpected errors are still printed with their traceback (starting with rutis: websockets:). In the dial: state lines, a heartbeat timeout's reason is now heartbeat timeout instead of closed (1011): keepalive ping timeout.
  • A far end revoked during its handshake still got a session (#432, found by the TLA+ models): two places. A link whose far end was revoked during the handshake provided the Peer and reported Ready before cutting it off, so plugins depending on the Peer could already have started loading rows; on an access point, an id revoked while a new connection of that id, already admitted, waited to take over was still accepted and then cut off. A link now checks for revocation before providing the Peer (the listening side refusing with close code 4003), and an access point before accepting.
  • A reload removing a runtime waited for the wrong process (#450, rutis-host): once a removed local runtime stops, the reload waits for its own process (also one its supervisor restarted meanwhile), not for any process that ran before: a runtime already down no longer stalls it 15 s with a false warning, and another runtime ending meanwhile no longer makes it say stopped early. Rust library: rutis-bridge gains transport::local::Processes, LocalTransport::sharing / processes and LocalRuntime::processes.
  • A stale name-clash refusal failed a later restart (#450): a row refused a name it provided after loading fails only the restart that refusal causes; later restarts (the clash long gone) run.
  • Services a Python thread provided slipped past a reload (#450, Plugin API): an undeclared service ctx.provided from another thread before apply returns now also has the host answer before the load does; on a clash the load fails, so the reload is refused and the old rows run on. Go did so already; Node and Bun are single-threaded.
  • The TypeScript SDK's declarations failed tsc --strict without skipLibCheck (#440): Plugin in @arcships/rutis extended two types that declare inject and provides differently (TS2320). It now takes them from one of them; the types are the same.

Tests and quality

Step three of the quality plan is done:

  • Concurrency models and fuzzing (#179 → #425): three shuttle models check, on the kernel's own code, the three places that went wrong before (a lost wakeup in TransitionTask, the race between post_join and the driver exiting, concurrent disposes cleaning up exactly once); three cargo-fuzz targets: session frame decoding, local line framing, WebSocket upgrade requests, with their corpora in the repository. Large runs nightly.
  • Cross-version combinations (#209 → #426): the previous release's runtimes and nodes against the current host (tests/e2e/tests/cross_version.rs), in the full runs (nightly, release gate); no combination failed after loading or hung.
  • S5 on a real network (#341 → #433): two containers, non-loopback addresses with TLS, netem adding delay, loss and outages; nightly, report only.
  • S6 published Cordis plugins (#190 → #429): rutis.json mounting published dsh plugins, plus a nightly baseline following the latest Cordis plugins; the gap it found, #428, is solved in this release (see "New").
  • S7 Rust embedding with multiple tenants (#191 → #430): a multi-tenant application assembled as in Embed rutis in a Rust application, creating, editing and closing tenants and coming back after a restart; after repeated creation and closing, internal tables, processes, descriptors and memory return to their baseline.
  • S8 long runs (#192 → #431): one rutis-host run runs an hour nightly on three platforms, calling, editing and rereading its configuration, killing runtimes and dropping links at random from a seed, with no resource growth; ending by Ctrl-C, SIGTERM or kill -9 leaves no orphan processes.
  • TLA+ remote leases (#210 → #432): two models in specs/remote-lease/ (a remote runtime's lease takeover and reconnection; access points and revocation), with a new CI job specs.
  • Language runtimes organised as a registry (#230 → #420): one file per language in rutis-host, test helpers moved to common, ready for the new runtimes of 0.13; no user-visible change.
  • Test fixes from the release review (#451): assertions that could pass vacuously and timing-dependent waits removed; the cross-version tests cover this release's three new behaviours against older versions: undeclared services (an older runtime under the current host, the current runtime under 0.10 and 0.11 hosts), leasing per row (two rows in an older Node or Python runtime each told apart), and an error with code and data sent to an older node.

Compatibility

  • Plugin API and protocol: the plugin API version is still 2, and the protocol versions are unchanged (protocol 2 for local sessions, 3 for sessions with endpoint identities). Every addition is negotiated and applies only when both sides are 0.12: announce in the mount arguments and rows.announce in its reply's features, a fourth argument { row, methods } on service for an undeclared service, announces in the rows.schema reply and in the Go manifest's plugin entries, and cordis for a Cordis plugin. Leasing per row (a Rust service seeing its calling row) uses only scope labels, the wire is unchanged, and 0.11 runtimes work with it. An error's code and data are in the error graph; 0.11 runtimes and hosts still get only the name and message.
  • A change in behaviour for 0.11-era plugins: an undeclared ctx.provide used to panic in Go (Provides does not declare it), stay visible only in its process on the other runtimes, and fail the testing tools' service(name) ("not declared in provides"); now it reaches rutis. So when a plugin provides, for its own process, a name another provider (any language, any node) also provides, the row providing it later now fails: rename it, or list the name in that row's isolate to keep it in the row's own scope.
  • check warnings and --strict (rutis-host): every plugin of the four 0.12 SDKs says announces: true (one declaring provides too; the declared names still count as provided), and so do Python and Bun module-style plugins without provides, and a Cordis row without rutis.provides. A dependency no row declares, while there are such rows, was cannot run: nothing provides … with exit status 1; it is now a warning on stderr, rutis-host: warning: <row>: nothing declares <service>; it may be provided at runtime by <rows>, …, with exit status 0. So in a project with such rows, a misspelt name in inject is only a warning: in CI use the new check --strict, which makes these warnings errors, exiting with 1. With no row that may provide it, it is still an error. A plugin of the 0.11 SDK has no announces mark, so check takes its declaration as all it provides.
  • Upgrade the runtime packages together with rutis-host: a 0.11 runtime under a 0.12 host follows its declarations, its undeclared services visible only in its process; a 0.12 runtime under a 0.11 host does not hand undeclared services over either, and a plugin providing one is told, once per name on stderr by the runtime (Node, Bun, Python, Go): rutis: service <name> is not declared in provides, and this host (older than 0.12) does not take undeclared services; declare it or upgrade rutis-host.
  • Inferred methods differ by language: without a declaration, the methods rutis sees follow each language's rules (JavaScript includes the prototype chain's functions, so a class extending EventEmitter also exposes on, emit and the rest; Python, public callable attributes; Go, exported methods), so the same service written in two languages can differ; list the methods in provides to fix them. A Python class-form provides (provides={"weather": Weather}) still makes only async def methods async and the rest sync, while inferred methods of an undeclared service are all async; this is unchanged, for compatibility with 0.11 code.
  • Errors carry code and data: a JavaScript error's string code property and its data property did not cross before and now go with the error to the far end; the receiver's error has these two properties (on Python's RemoteError they are None when absent).
  • rutis.json: the format is still 1. runtimes.node, runtimes.py and runtimes.bun gain the optional field restart; earlier files need no change and mean the same; a file using it cannot be read by the 0.11 rutis-host (an unknown field). A misspelt field in these three runtimes now lists restart among the fields allowed.
  • Exit status: 3 is new (a runtime whose restart is "exit" ended, and the host stopped). 0, 1 and 2 mean what they did.
  • Credentials: rutis-host now reads RUTIS_TOKEN_<NODE> / RUTIS_TOKEN when a link dials or a far end dials in; the values are the same as before (the environment does not change within the process), only the peer rows no longer have to be there at start.
  • Rust API (cargo semver-checks against v0.11.0):
    • rutis-loader: ServiceCatalog::new() / default() now share by name every name not registered otherwise, as rutis-host's catalog (share_by_name) always did. With #428 only names that have a provider on the rutis side gate rows in rutis, so Cordis rows no longer wait on each other for it. Differences an embedding application may see: a row injecting a name nothing registers waits for it (it was UnknownService), and a Cordis row's injected names are gated in rutis like a leaf row's. ServiceCatalog::share_registered_only() is the former behaviour; share_by_name() stays (it is now the default).
    • rutis-loader's Declared gains the public field announces; rutis-bridge's runtime::RowSchema the public fields announces and cordis; rutis-host's config::NodeRuntime, BunRuntime and PythonRuntime the public field restart. Code building them with a struct literal needs the fields (or ..Default::default()).
    • rutis-host: status::follow now takes one status::Followed, and Shown::changes takes &Followed (both took a loader and a PeerResolver before).
    • rutis has no changes; everything else is an addition, see the entries above.
  • dylib: dylib plugins need to be rebuilt with the 0.12.0 SDK.
  • Minimum versions unchanged: Rust 1.88, Node 22, Python 3.10, Bun 1.4, Go 1.24.

Known issues

  • Go runtimes have no restart setting yet: a crashed Go runtime stays down, and starts again when a row uses it once its binary changed.
  • As in 0.11: Bun cannot tell "the server's certificate is not trusted" from other TLS handshake failures, so a Bun dial-out treats every TLS handshake failure as an authentication failure and retries every 30 seconds; on Windows, a Node dial-out relies on the console sending Ctrl-C to child processes too in order to stop, untested on Windows.

Getting started

npx @arcships/rutis-host@0.12.0 new greeter --lang node
uvx --from rutis-host==0.12.0 rutis-host new greeter-py --lang python

Then read TypeScript plugins, Bun plugins, Python plugins, Go plugins, Embed rutis in a Rust application or Connect Nodes.