bitruntime

module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2026 License: Apache-2.0

README

bitruntime

The Go and TypeScript implementation of the bitwire contract.

Status: the runtime path hand-written adapters use is implemented (the next release after the structural core 0.1.0):

  • core: full tree construction, selection, decomposition and derived sending; the addressed operators At, Mount and Forward; the local pair; the invocation lifecycle.
  • transports: the frame transport seam, the in-memory pipe and WebSocket.
  • engine: the bitwire/1 protocol engine and WebSocket connection setup.
  • dispatch: the dispatcher and the Call, Emit, Handle and Register helpers.

The runtime is ported from nightseam v0.6.0 with its provenance in NOTICE, and fixes nightseam's recorded defects in this path; see the port record. The engine interoperates with nightseam v0.6.0 peers in both roles and both languages and sends the same bytes (node scripts/interop.mjs). Live references, tunnels, the framed byte stream, telemetry and authentication integration remain planned under bitwire decision 0010.

Where it sits

bitruntime  →  bitwire (the contract, the protocol and carrier specifications, conformance)
  • bitwire specifies addressless Wire, structural WireTree, and the separate AddressedWire carrier access contract. bitruntime implements them.
  • bitwire's conformance cases judge bitruntime as an external implementation, written from the specification and never recorded from this code.
  • What bitruntime depends on. bitwire, and in separate modules, the libraries a transport needs.
  • What it does not depend on. The contract language (bittype), the adapters (bitlink), or nightseam.

The primitive and tree contract

The maintainer's accepted naming is symmetric across interaction and storage:

interface Wire { send(message: Message): void; }
interface Data { read(): Promise<Bytes>; }

type WireTree = DeixisNode<Wire>;
type DataTree = DeixisNode<Data>;

Both trees have the same full deixis structure: an own primitive, complete children keyed by exact bytes, partial path selection, decomposition and reconstruction. For a present path:

send(tree, path, message) = select(tree, path).own().send(message)
read(tree, path)          = select(tree, path).own().read()

Wire belongs to bitwire; Data belongs to bitstore. A Data is a reading capability. A materialized DeixisNode<Bytes> remains the codec snapshot, not the definition of DataTree.

The old path-taking interface is explicitly AddressedWire. It can be an opaque router and does not provide a WireTree's structural guarantees. Endpoint extends that access contract and owns receiving/closing; the bitwire/1 profile and return capabilities retain addressed access. The runtime must provide explicit bridges without inventing children for opaque peers.

See the contract and migration boundaries. The structural core implements these tree obligations. It does not infer a tree from an opaque addressed endpoint, queue invocations, or own endpoint lifetime. Derived sending preserves the selected primitive's admission/refusal and message/return-capability identity.

Two explicit bridges carry a tree across a carrier, which names positions, not nodes:

  • Bind/bind gives the near side an addressless Wire that sends at one fixed addressed path; a near tree binds each far position it names.
  • Serve/serve gives the far side one exact dispatcher route per position whose keys are UTF-8, bound to that position's own Wire. Update replaces the served tree atomically, and a request admitted before a replacement keeps the node that admitted it, its cancellation included.

Packages

Go uses one module, github.com/Bitspark/bitruntime, released by root tags:

Package Holds
core/go Trees, At, Bind, Mount, Forward, NewPair, the invocation lifecycle, Respond, PublicError
transports/go The seam, Pipe, close codes and Sendable, the closed classification ErrClosed
transports/websocket/go The WebSocket transport
engine/go The bitwire/1 Peer over any transport
engine/websocket/go Accept, NewHandler and Dial over WebSockets
dispatch/go NewDispatcher and its atomically replaced RouteSet, Serve, Call, Emit, Handle, Register

A program links only the packages it imports; coder/websocket and net/http enter only through the WebSocket packages. TypeScript uses one package, @bitspark/bitruntime, built at the repository root with the subpaths ./core, ./transports, ./engine and ./dispatch, so the received context its components share stays private to the package. (v0.1.0 shipped the structural core alone as @bitspark/bitruntime-core.) Both depend on the public bitwire 0.3.0 contract. Releases publish a root Go tag and a TypeScript tarball with checksums on GitHub; npm registry publication is not configured. Read RELEASING.md.

To install a release, require the Go module at its tag and the TypeScript package from its release asset:

go get github.com/Bitspark/bitruntime@v0.3.0
npm install https://github.com/Bitspark/bitruntime/releases/download/v0.3.0/bitspark-bitruntime-0.3.0.tgz

npm 12 refuses dependencies that are tarball URLs unless the project allows them. Add allow-remote=root to the project's .npmrc; it admits only the URLs the project's own package.json names. Where a user configuration maps the @bitspark scope to another registry, also pin @bitspark:registry=https://registry.npmjs.org/ there, since the package's dependency @bitspark/bitwire comes from npm.

The generic core uses bitwire's native node declarations. TypeScript accepts bitstore's matching structural node type directly; Go requires an explicit adapter between the two packages' recursive node types. The shared semantic contract does not imply direct Go assignability.

Read first

Source layout

Read LAYOUT.md for the component-first, two-letter language directory convention and this repository's adoption notes.

Directories

Path Synopsis
conformance
interop/bitruntime/go command
Command bitruntime-interop is bitruntime's Go program of the interoperability scenario in conformance/interop/README.md.
Command bitruntime-interop is bitruntime's Go program of the interoperability scenario in conformance/interop/README.md.
interop/recorder/go command
Command interop-recorder speaks bitwire/1 frames by hand to a server of the interoperability scenario and prints, one per line, every frame the server sent back and how the connection ended.
Command interop-recorder speaks bitwire/1 frames by hand to a server of the interoperability scenario and prints, one per line, every frame the server sent back and how the connection ended.
core
go
Package core constructs full Deixis trees and derives sending from selection.
Package core constructs full Deixis trees and derives sending from selection.
dispatch
go
Package dispatch routes addressed deliveries to handlers and provides the request, response and event helpers adapters use.
Package dispatch routes addressed deliveries to handlers and provides the request, response and event helpers adapters use.
engine
go
Package engine implements the bitwire/1 protocol over a frames duplex connection: JSON text frames carrying requests, responses, events and cancellations, correlated by serial request identifiers.
Package engine implements the bitwire/1 protocol over a frames duplex connection: JSON text frames carrying requests, responses, events and cancellations, correlated by serial request identifiers.
websocket/go
Package websocket sets up bitwire/1 connections over WebSockets: Accept and NewHandler serve the protocol at an HTTP endpoint, and Dial connects to one.
Package websocket sets up bitwire/1 connections over WebSockets: Accept and NewHandler serve the protocol at an HTTP endpoint, and Dial connects to one.
internal
delivery/go
Package delivery is the received context bitruntime's own carriers establish and its own helpers recognize.
Package delivery is the received context bitruntime's own carriers establish and its own helpers recognize.
profile/go
Package profile holds the bitwire/1 envelope: its JSON frame, the canonical encoding of an addressed path into the frame's method or event name, and the validation a peer applies before it admits a frame.
Package profile holds the bitwire/1 envelope: its JSON frame, the canonical encoding of an addressed path into the frame's method or event name, and the validation a peer applies before it admits a frame.
request/go
Package request is the request primitive shared by the public call helper and the protocol engine's inbound bridge: one request sent through addressed access with a fresh return capability that carries its invocation lifecycle, and the wait for its one response.
Package request is the request primitive shared by the public call helper and the protocol engine's inbound bridge: one request sent through addressed access with a fresh return capability that carries its invocation lifecycle, and the wait for its one response.
transports
go
Package transports is the seam beneath every carrier: a frames duplex connection.
Package transports is the seam beneath every carrier: a frames duplex connection.
go/transporttest
Package transporttest holds every transport to what a frames duplex connection promises.
Package transporttest holds every transport to what a frames duplex connection promises.
websocket/go
Package websocket carries a frames duplex connection over a WebSocket, and is the only package that knows the seam is one: a message is a frame, a close frame is a close, and the read limit is the receive limit.
Package websocket carries a frames duplex connection over a WebSocket, and is the only package that knows the seam is one: a message is a frame, a close frame is a close, and the read limit is the receive limit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL