wire

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 1 Imported by: 2 modules, 8 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Bitwire for Go

Source contract: 0.3.0; publication pending. Wire is the addressless primitive send(message). WireTree = DeixisNode<Wire> provides the complete finite, acyclic structure: own value, complete byte-keyed children, partial selection and decomposition. Keys are exact arbitrary bytes, including empty and non-UTF-8 keys. Empty path selects self; a missing edge is distinct from a present refusing primitive. Recomposition preserves own and child identities.

This is symmetric with Bitstore's Data.read() primitive and DataTree = DeixisNode<Data>. Derived sending selects the node and invokes its own Wire. Construction and derived operators belong in bitruntime; these packages publish declarations and criteria, not a production tree runtime. See decision 0012 and the migration guide.

AddressedWire explicitly names the former Wire.send(path, message) surface. It is not a full WireTree. Endpoint extends AddressedWire, and return capabilities retain AddressedWire so the existing response/lifecycle path space, local identity, received context and closure rules remain intact. Carrier paths remain exact Unicode-scalar strings under unchanged bitwire/1; they do not imply support for arbitrary tree byte keys on that carrier.

The following addressed-carrier examples use the 0.3 source names. Older 0.2.0 artifacts used Wire for the addressed interface; their release evidence does not validate the renamed declarations or full structural trees.

Package github.com/Bitspark/bitwire/wire/go, named wire, presents the 0.3 AddressedWire contract. It uses only the Go standard library.

type AddressedWire interface {
    Send(path []string, message Message) error
}

type Endpoint interface {
    AddressedWire
    Receive(receiver Receiver) (detach func(), err error)
    Close(code Code, reason string) error
}

wire.go contains the supporting frame, return-address and receiver types. After 0.3.0 is published, install that module with:

go get github.com/Bitspark/bitwire@v0.3.0

AddressedWire grants send access. Endpoint additionally grants one owning receive attachment and lifecycle control. A ReturnAddress needs only AddressedWire. The receiver sees each complete message and its relative path; it has no registration path or namespace option. Shared selection and handler routing belong to an explicit dispatcher composition.

There is no endpoint implementation in this package. Nightseam implementations of the 0.1 contract require an adoption change or bridge for 0.2.

From the repository root, go vet ./... and go test ./... check the package and its send-only consumer example. The independent conformance work records behavioral evidence separately from declaration and package installation checks.

Documentation

Overview

Package wire declares the Bitwire 0.3 primitive, tree and addressed carrier contracts. It defines the shared boundary; dispatch, codecs and carriers belong to implementations. TreePath uses exact byte keys. The separate bitwire/1 AddressedWire carrier retains Unicode-scalar string paths without normalization.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressedWire added in v0.3.0

type AddressedWire interface {
	Send(path []string, message Message) error
}

AddressedWire is send access to an origin. It grants neither receive attachment nor endpoint lifecycle control. Send returns when accepted or refused, without running a destination handler on the sender's stack or waiting for its result. Success means admission, not completion of an application effect.

Example
package main

import (
	"fmt"

	wire "github.com/Bitspark/bitwire/wire/go"
)

// A consumer can provide access without receiver or lifecycle operations.
type sendOnly func([]string, wire.Message) error

func (send sendOnly) Send(path []string, message wire.Message) error {
	return send(path, message)
}

func main() {
	access := sendOnly(func(path []string, message wire.Message) error {
		fmt.Println(path, message.Frame.Kind)
		return nil
	})
	address := &wire.ReturnAddress{Wire: access}
	_ = address.Wire.Send([]string{"result"}, wire.Message{
		Frame: wire.ProfileFrame{Version: 1, Kind: wire.ProfileEvent, Data: []byte("null")},
	})
}
Output:
[result] event

type Child added in v0.3.0

type Child[T any] struct {
	Key  Key
	Tree DeixisNode[T]
}

Child is one complete named subtree. Children form a finite map by key bytes.

type Code

type Code int

Code is a wire termination code. Meaning and defaults follow the profile.

type DeixisNode added in v0.3.0

type DeixisNode[T any] interface {
	Own() T
	Children() []Child[T]
	At(path TreePath) (DeixisNode[T], bool)
	Decompose() (T, []Child[T])
}

DeixisNode is the full finite, acyclic structural contract, not an opaque routing handle. Its topology and own-value associations remain stable. Children and Decompose return the complete child map with exact keys. At returns (nil,false) for a missing path, never a fabricated proxy. Decomposition followed by reconstruction preserves structure and payload capability identity. Construction and derived operations belong to runtimes.

type Endpoint added in v0.2.0

type Endpoint interface {
	AddressedWire
	Receive(receiver Receiver) (detach func(), err error)
	Close(code Code, reason string) error
}

Endpoint combines send access with receive attachment and lifecycle control. Receive attaches one owning receiver for every relative path. A second attachment is refused until the first is detached. Detach is idempotent and does not close the endpoint. Path dispatch and sharing among selected views belong to an explicit composition, not this primitive.

type Key added in v0.3.0

type Key = []byte

Key is an exact byte string. Empty keys and arbitrary binary bytes are valid. Implementations copy mutable key inputs/outputs to preserve tree structure.

type Message

type Message struct {
	Frame  ProfileFrame
	Return *ReturnAddress `json:"-"`
}

Message preserves a frame, its local capability and associated received context through routing. Context is established and recognized by the runtime, not inferred from caller-supplied payloads or metadata. Keep the message's contents immutable after Send admits it; implementations may retain them.

type ProfileError

type ProfileError struct {
	Code    string          `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}

ProfileError is public error data, without a runtime error dependency. Its fields do not prove that a failed send was never published. That local evidence, when required by value conversion, belongs to the admitting runtime.

type ProfileFrame

type ProfileFrame struct {
	Version     int               `json:"version"`
	Kind        ProfileKind       `json:"kind"`
	ID          string            `json:"id,omitempty"`
	Params      json.RawMessage   `json:"params,omitempty"`
	Result      json.RawMessage   `json:"result,omitempty"`
	Error       *ProfileError     `json:"error,omitempty"`
	Data        json.RawMessage   `json:"data,omitempty"`
	Traceparent string            `json:"traceparent,omitempty"`
	Tracestate  string            `json:"tracestate,omitempty"`
	Meta        map[string]string `json:"meta,omitempty"`
}

ProfileFrame carries a profile frame. An AddressedWire path is the request method or event name; keeping it outside this value prevents contradictory names. Payloads retain their JSON representation, including numeric precision. A nil RawMessage means absent; the bytes "null" mean present JSON null. Only fields allowed for Kind may be populated, and Version must be 1. The profile implementation validates those conditions at its boundary.

type ProfileKind

type ProfileKind string

ProfileKind is one of the profile's four frame kinds. Correlation and validation remain the peer's; a wire only carries the frame.

const (
	ProfileRequest  ProfileKind = "request"
	ProfileResponse ProfileKind = "response"
	ProfileEvent    ProfileKind = "event"
	ProfileCancel   ProfileKind = "cancel"
)

type Receiver

type Receiver struct {
	Message func(path []string, message Message)
	Closed  func(code Code, reason string)
}

Receiver receives complete deliveries relative to its endpoint's origin, and an ending. The endpoint owns asynchronous dispatch. Receiver contains no routing policy; a dispatcher may interpret paths after delivery.

type ReturnAddress

type ReturnAddress struct{ Wire AddressedWire }

ReturnAddress is a local capability with stable pointer identity, even when its AddressedWire implementation is not comparable. Routing must preserve the pointer and any runtime-owned context associated with it. It is never an envelope member. A runtime may use it to retain an event's received context without providing a callable reply or creating a response waiter.

type TreePath added in v0.3.0

type TreePath = [][]byte

TreePath selects a descendant through exact byte keys; the empty path is self. This is distinct from the bitwire/1 carrier's Unicode string paths.

type Wire

type Wire interface {
	Send(message Message) error
}

Wire is addressless sending access. Send completes on admission or refusal, not application completion, and grants no receiver or endpoint ownership. Message/frame semantics are unchanged from the selected profile.

Example
package main

import (
	"fmt"

	wire "github.com/Bitspark/bitwire/wire/go"
)

// The primitive has no path. A carrier address cannot silently become a tree.
type primitive func(wire.Message) error

func (send primitive) Send(message wire.Message) error { return send(message) }

func main() {
	access := primitive(func(message wire.Message) error {
		fmt.Println(message.Frame.Kind)
		return nil
	})
	_ = access.Send(wire.Message{Frame: wire.ProfileFrame{Version: 1, Kind: wire.ProfileEvent}})
}
Output:
event

type WireTree added in v0.3.0

type WireTree = DeixisNode[Wire]

WireTree is a full Deixis tree with one addressless Wire at every node. Derived sending selects a node and calls its own Wire.Send(message). An arbitrary AddressedWire cannot be reconstructed into a WireTree.

Jump to

Keyboard shortcuts

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