diff --git a/.github/workflows/prepare-source.yml b/.github/workflows/prepare-source.yml new file mode 100644 index 0000000..e93612e --- /dev/null +++ b/.github/workflows/prepare-source.yml @@ -0,0 +1,37 @@ +name: prepare-source +on: + pull_request: + workflow_dispatch: +permissions: + contents: read +jobs: + prepare: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - uses: actions/setup-go@v7 + with: + go-version-file: go.mod + cache: false + - uses: actions/setup-node@v7 + with: + node-version: 24 + - name: Prepare formatting and dependency locks on the runner + shell: bash + run: | + trap 'git diff --binary > "$RUNNER_TEMP/source-preparation.patch"' EXIT + git ls-files -z '*.go' | xargs -0 -r gofmt -w + go mod tidy + npm install --package-lock-only --ignore-scripts --registry=https://registry.npmjs.org/ + node scripts/naming.mjs --fix + - uses: actions/upload-artifact@v7 + if: always() + with: + name: source-preparation + path: ${{ runner.temp }}/source-preparation.patch + retention-days: 7 + - name: Prepared artifacts must be committed + run: git diff --exit-code diff --git a/README.md b/README.md index 30f6213..2815d30 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # bitruntime -Go and TypeScript implementations of [bitwire 0.6.0](https://github.com/Bitspark/bitwire/tree/v0.6.0): addressless endpoints, addressed access, complete byte-keyed trees, local pairs and WebSocket carriers, and the hydrated layer of [decision 0019](https://github.com/Bitspark/bitwire/blob/v0.6.0/docs/decisions/0019-hydrated-wire-protocol.md) ([hydrated/README.md](hydrated/README.md)). +Go and TypeScript implementations of [bitwire 0.7.0](https://github.com/Bitspark/bitwire/tree/v0.7.0): addressless endpoints, addressed access, complete byte-keyed trees, local pairs and WebSocket carriers, and the hydrated layer of [decision 0019](https://github.com/Bitspark/bitwire/blob/v0.7.0/docs/decisions/0019-hydrated-wire-protocol.md) ([hydrated/README.md](hydrated/README.md)). Wire grants sending ground ontos values. Endpoint adds one detachable receive owner, termination and closure. AddressedWire adds a separate path parameter; an AddressedEndpoint presents that layer over an existing endpoint. WireNode is a complete deixis tree whose own values are send capabilities. @@ -9,11 +9,11 @@ Wire grants sending ground ontos values. Endpoint adds one detachable receive ow Install the release package and shared contract: ```sh -npm install --allow-remote=root --@bitspark:registry=https://registry.npmjs.org @bitspark/bitwire@0.6.0 https://github.com/Bitspark/bitruntime/releases/download/v0.7.1/bitspark-bitruntime-0.7.1.tgz +npm install --allow-remote=root --@bitspark:registry=https://registry.npmjs.org @bitspark/bitwire@0.7.0 @bitspark/ontos-core@0.16.0 https://github.com/Bitspark/bitruntime/releases/download/v0.8.0/bitspark-bitruntime-0.8.0.tgz ``` ```ts -import { atom } from '@bitspark/bitwire'; +import { atom } from '@bitspark/ontos-core'; import { pair, addressed, bind } from '@bitspark/bitruntime/core'; const [left, right] = pair(); @@ -34,7 +34,7 @@ A raw endpoint can send an atom directly. The addressed facade works on the same ## Go ```sh -go get github.com/Bitspark/bitruntime@v0.7.1 +go get github.com/Bitspark/bitruntime@v0.8.0 ``` Use `core/go.NewPair` and `websocket/go.Dial`, `Accept`, `NewServer` or `Listen`. They return bitwire Endpoints. `core/go.Addressed`, `Bind`, `Under` and `AsAddressed` implement the same layering as TypeScript; absent tree paths return ErrMissingPath. `hydrated/go` provides `NewScope`, `NewEndpoint`, `NewNamespace` and `NewTuple` over bitwire's hydrated declarations. A receiver runs on its endpoint's dispatcher. Close does not wait for or cancel dispatched application work. diff --git a/RELEASING.md b/RELEASING.md index 9abd513..8eed8ed 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,6 +1,6 @@ # Releasing -One root `vX.Y.Z` tag versions the Go module and TypeScript package together. bitruntime 0.7.1 implements bitwire 0.6.0: raw ontos-codec-v1 messages, the optional `bitwire/addressed/1` layer, WebSocket `bitwire.ontos.v2` and the hydrated layer `bitwire/hydrated/1` (decision 0019). +One root `vX.Y.Z` tag versions the Go module and TypeScript package together. bitruntime 0.8.0 implements bitwire 0.7.0 with public ontos 0.16.0: raw ontos-codec-v1 messages, the optional `bitwire/addressed/1` layer, WebSocket `bitwire.ontos.v2` and the hydrated layer `bitwire/hydrated/1` (decision 0019). - Go module: `github.com/Bitspark/bitruntime`, packages `core/go`, `websocket/go` and `hydrated/go`. - TypeScript package: `@bitspark/bitruntime`, subpaths `/core`, `/websocket` and `/hydrated`. diff --git a/conformance/interop/go/main.go b/conformance/interop/go/main.go index 417e672..b1a2dbe 100644 --- a/conformance/interop/go/main.go +++ b/conformance/interop/go/main.go @@ -7,8 +7,8 @@ import ( "fmt" core "github.com/Bitspark/bitruntime/core/go" ws "github.com/Bitspark/bitruntime/websocket/go" - ontos "github.com/Bitspark/bitwire/ontos/go/core" wire "github.com/Bitspark/bitwire/wire/go" + ontos "github.com/bitspark/ontos/core/go" "net/http" "os" "time" diff --git a/conformance/interop/hydrated/main.go b/conformance/interop/hydrated/main.go index 4e0940a..40cbf13 100644 --- a/conformance/interop/hydrated/main.go +++ b/conformance/interop/hydrated/main.go @@ -23,8 +23,8 @@ import ( core "github.com/Bitspark/bitruntime/core/go" hydrated "github.com/Bitspark/bitruntime/hydrated/go" websocket "github.com/Bitspark/bitruntime/websocket/go" - ontos "github.com/Bitspark/bitwire/ontos/go/core" wire "github.com/Bitspark/bitwire/wire/go" + ontos "github.com/bitspark/ontos/core/go" ) var ( diff --git a/core/go/addressed.go b/core/go/addressed.go index 0ed2890..bd366cc 100644 --- a/core/go/addressed.go +++ b/core/go/addressed.go @@ -2,8 +2,8 @@ package core import ( "errors" - ontos "github.com/Bitspark/bitwire/ontos/go/core" wire "github.com/Bitspark/bitwire/wire/go" + ontos "github.com/bitspark/ontos/core/go" ) // Addressed is an inert facade over the same endpoint and its receive ownership. diff --git a/core/go/addressed_test.go b/core/go/addressed_test.go index 6ab9034..778d13d 100644 --- a/core/go/addressed_test.go +++ b/core/go/addressed_test.go @@ -3,8 +3,8 @@ package core_test import ( "errors" core "github.com/Bitspark/bitruntime/core/go" - ontos "github.com/Bitspark/bitwire/ontos/go/core" wire "github.com/Bitspark/bitwire/wire/go" + ontos "github.com/bitspark/ontos/core/go" "testing" ) diff --git a/core/go/node_boundary_test.go b/core/go/node_boundary_test.go index b514921..b9e5d98 100644 --- a/core/go/node_boundary_test.go +++ b/core/go/node_boundary_test.go @@ -5,9 +5,9 @@ import ( "testing" core "github.com/Bitspark/bitruntime/core/go" - ontos "github.com/Bitspark/bitwire/ontos/go/core" wire "github.com/Bitspark/bitwire/wire/go" deixis "github.com/bitspark/deixis/core/go" + ontos "github.com/bitspark/ontos/core/go" ) type boundarySlot struct { diff --git a/core/go/pair.go b/core/go/pair.go index 6864397..74ac02e 100644 --- a/core/go/pair.go +++ b/core/go/pair.go @@ -3,8 +3,8 @@ package core import ( "errors" - ontos "github.com/Bitspark/bitwire/ontos/go/core" wire "github.com/Bitspark/bitwire/wire/go" + ontos "github.com/bitspark/ontos/core/go" "sync" ) diff --git a/core/go/pair_test.go b/core/go/pair_test.go index 17e9036..3c4b3a0 100644 --- a/core/go/pair_test.go +++ b/core/go/pair_test.go @@ -2,8 +2,8 @@ package core_test import ( core "github.com/Bitspark/bitruntime/core/go" - ontos "github.com/Bitspark/bitwire/ontos/go/core" wire "github.com/Bitspark/bitwire/wire/go" + ontos "github.com/bitspark/ontos/core/go" "testing" "time" ) diff --git a/core/go/tree.go b/core/go/tree.go index 1184608..aca6d55 100644 --- a/core/go/tree.go +++ b/core/go/tree.go @@ -2,8 +2,8 @@ package core import ( "errors" - ontos "github.com/Bitspark/bitwire/ontos/go/core" wire "github.com/Bitspark/bitwire/wire/go" + ontos "github.com/bitspark/ontos/core/go" "reflect" ) diff --git a/core/ts/src/addressed.ts b/core/ts/src/addressed.ts index 7dca56f..80289d5 100644 --- a/core/ts/src/addressed.ts +++ b/core/ts/src/addressed.ts @@ -1,6 +1,5 @@ -import { capturePath, packAddressed, unpackAddressed, - type Endpoint, type AddressedEndpoint, type Wire, type AddressedWire, - type WireNode, type Path, type Value } from '@bitspark/bitwire'; +import { type Value } from '@bitspark/ontos-core'; +import { capturePath, packAddressed, unpackAddressed, type Endpoint, type AddressedEndpoint, type Wire, type AddressedWire, type WireNode, type Path } from '@bitspark/bitwire'; // Inert facade: receiving is attached only by receive(), with the raw owner's lifetime. export function addressed(endpoint: Endpoint): AddressedEndpoint { diff --git a/core/ts/src/pair.ts b/core/ts/src/pair.ts index 1feb734..b5f6d4c 100644 --- a/core/ts/src/pair.ts +++ b/core/ts/src/pair.ts @@ -1,4 +1,5 @@ -import { encodeMessage, type Value, type Endpoint, type Termination } from '@bitspark/bitwire'; +import { type Value } from '@bitspark/ontos-core'; +import { encodeMessage, type Endpoint, type Termination } from '@bitspark/bitwire'; import { pairOptions, type PairOptions } from './limits.ts'; class PairEndpoint implements Endpoint { readonly closed: Promise; diff --git a/core/ts/src/tree.ts b/core/ts/src/tree.ts index 190d70c..0f2d6a7 100644 --- a/core/ts/src/tree.ts +++ b/core/ts/src/tree.ts @@ -1,4 +1,5 @@ -import { Atom, type Children, type DeixisNode, type Value, type Path } from '@bitspark/bitwire'; +import { Atom, type Value } from '@bitspark/ontos-core'; +import { type Children, type DeixisNode, type Path } from '@bitspark/bitwire'; export function compose(own: T, children: Children = []): DeixisNode { const captured: Children = Object.freeze(children.map(([key,node])=> { if(!(key instanceof Atom)||!node)throw new TypeError('invalid child'); diff --git a/core/ts/test/addressed.test.mjs b/core/ts/test/addressed.test.mjs index 7c5c6d4..db3929b 100644 --- a/core/ts/test/addressed.test.mjs +++ b/core/ts/test/addressed.test.mjs @@ -1,6 +1,7 @@ import {test} from 'node:test'; import assert from 'node:assert/strict'; -import {atom,tuple,pathEqual} from '@bitspark/bitwire'; +import { atom, tuple } from '@bitspark/ontos-core'; +import { pathEqual } from '@bitspark/bitwire'; import {checkAddressedEndpoints} from '@bitspark/bitwire/conformance'; import {pair,addressed,bind,under,asAddressed,compose,MissingPathError} from '../../../dist/core/ts/src/index.js'; diff --git a/core/ts/test/node-boundary.test.mjs b/core/ts/test/node-boundary.test.mjs index cfe900e..7378205 100644 --- a/core/ts/test/node-boundary.test.mjs +++ b/core/ts/test/node-boundary.test.mjs @@ -1,7 +1,7 @@ import {test} from 'node:test'; import assert from 'node:assert/strict'; import {compose as composeBytes} from '@bitspark/deixis-core'; -import {atom, tuple} from '@bitspark/bitwire'; +import { atom, tuple } from '@bitspark/ontos-core'; import {compose, asAddressed, addressed, pair, route} from '../../../dist/core/ts/src/index.js'; // Each implementation is checked against these hand-written observations. The diff --git a/core/ts/test/node-types.ts b/core/ts/test/node-types.ts index 5b2ccfe..7bea4e8 100644 --- a/core/ts/test/node-types.ts +++ b/core/ts/test/node-types.ts @@ -1,5 +1,6 @@ import {compose as composeBytes, type DeixisNode as BytesNode} from '@bitspark/deixis-core'; -import {atom, type DeixisNode, type Wire, type WireNode} from '@bitspark/bitwire'; +import { atom } from '@bitspark/ontos-core'; +import { type DeixisNode, type Wire, type WireNode } from '@bitspark/bitwire'; import {compose, asAddressed} from '../src/index.js'; // Check each independently declared structural surface, rather than concealing diff --git a/core/ts/test/pair.test.mjs b/core/ts/test/pair.test.mjs index 4ab4f50..4bd1e66 100644 --- a/core/ts/test/pair.test.mjs +++ b/core/ts/test/pair.test.mjs @@ -1,6 +1,6 @@ import {test} from 'node:test'; import assert from 'node:assert/strict'; -import {atom,tuple} from '@bitspark/bitwire'; +import { atom, tuple } from '@bitspark/ontos-core'; import {checkWirePair} from '@bitspark/bitwire/conformance'; import {pair,compose,select,route} from '../../../dist/core/ts/src/index.js'; const e=(id=1)=>tuple([atom([id]),atom([0,255])]); diff --git a/docs/ONTOS-WIRE.md b/docs/ONTOS-WIRE.md new file mode 100644 index 0000000..d10747a --- /dev/null +++ b/docs/ONTOS-WIRE.md @@ -0,0 +1,32 @@ +# Shared native value migration + +The owner's 4 November 2026 migration moves Go and TypeScript mixed tuple +structure to the optional `ontos/wire` package. The runtime imports public ontos +0.16.0 and bitwire 0.7.0; all raw and hydrated ground values use that same family. +`hydrated.NewTuple` and `hydratedTuple` compose the shared factory with this +runtime's leaf recognition and endpoint-to-sending-face projection. They no +longer implement or own a separate tuple class. The old runtime tuple types are +removed; inspect structure with `Items` / `items`, or the ontos native tuple type. + +The factory is private. A tuple constructed under another policy is refused on +local delivery and before remote export staging. Qualified immutable children +retain their sharing; local admission does not unfold them. Ground-only tuples +still collapse to ground ontos tuples. Closed/stale capabilities remain structural +leaves; liveness is checked at the same operations as before. + +The runtime retains queues and dispatch, received context, namespaces, scopes, +random export identifiers, staged whole-value admission, aliases, proxies, +ownership and lifetime. Its D8 limits still count node occurrences, depth, +atom/reference bytes and encoded frames. The separate limits of explicit +ontos/deixis conversion are not imposed on native construction or sending. + +No transport bytes or negotiated protocol names change. Raw carriers and bitnode +routing still carry ground ontos frames. The pure hydrated reference/frame codec +remains in bitwire. The optional value package has no knowledge of transports, +Function, Stream, Cell or their behavior. + +Qualification retains every existing vector, ownership, alias, scope, lifetime, +deep/shared value, local/network and Go/TypeScript interoperability observation. +Additional tests reject tuples from foreign qualification factories and prove +that forged containers cannot conceal endpoint ownership. There are no legacy +decoders, duplicate value implementations or compatibility tuple aliases. diff --git a/docs/RELEASE.md b/docs/RELEASE.md index 11351b0..7d1b434 100644 --- a/docs/RELEASE.md +++ b/docs/RELEASE.md @@ -1,34 +1,26 @@ -# bitruntime 0.7.1 +# bitruntime 0.8.0 -0.7.1 publishes what 0.7.0 tagged: its library code is unchanged. The v0.7.0 -release run failed in its Go consumer smoke on Linux after the tag, so v0.7.0 -has a public Go module but no GitHub release or tarball. The smoke is fixed and -CI now runs it against each pushed commit. +This release uses bitwire 0.7.0 and public ontos 0.16.0. The optional ontos/wire +package owns the Go and TypeScript native mixed-value structure. The runtime +supplies its private capability-recognition and sending-face policy to that +factory. See the [migration contract](ONTOS-WIRE.md). -## The hydrated layer, introduced in 0.7.0 +The runtime's duplicate tuple implementation and exported tuple class/type are +removed. Use `hydratedTuple` / `NewTuple` for runtime-qualified construction and +`items` / `Items` for observation. Ground values come directly from the public +ontos packages; the old bitwire ground subpaths and re-exports are removed. -This release adds the hydrated wire layer, realizing bitwire decision 0019 over -bitwire 0.6.0's public hydrated declarations and shared pure codec. A message may -carry live Wires inside its structure. A Wire travels as a reference that its -receiver turns back into a usable send-only Wire. A reference returning to its -owner restores the original Wire. Routers between participants see only ground -values. +Transport bytes and protocol names remain unchanged: ontos-codec-v1, +bitwire/addressed/1, bitwire.ontos.v2 and bitwire/hydrated/1. Export/import, +namespace, ownership, lifetime, liveness, context, queue, dispatch and D8 counting +rules remain runtime responsibilities. Foreign-factory tuples cannot hide owner +handles from local or remote admission. Deep and shared native values retain +their existing operational behavior. -`hydrated/go` and the TypeScript subpath `/hydrated` provide: -- **Scopes.** One per participant incarnation, with a random token. Export ids - are 16 unpredictable octets, so one reference never reveals another. -- **Endpoints.** Their sending faces are the only exportable local Wires. An - export ends when its endpoint closes, a receiver failure terminates the - endpoint, and termination is reported as bitwire's `Termination`. -- **Proxies.** Recognized throughout the namespace, so forwarding never wraps a - proxy in another. -- **Liveness and context.** Liveness is judged on send. The composition's - received context is delivered beside each value, never inside it. -- **Bounds.** Nodes, depth and bytes are counted one way in both directions. - Conversion refuses before allocating, and incoming frames count whole. +The complete release gate retains Go race tests, TypeScript checks and tests, +independent vectors, composition conformance, bidirectional Go/TypeScript +interoperability, and fresh installed consumers. Go is distributed through the +root tag; the TypeScript archive is a GitHub release asset with SHA256SUMS. -Validation covers decision 0019's observations in Go and TypeScript, the -independent vectors, the composition conformance suite, Go race tests, -Go/TypeScript hydrated interoperability in both roles and fresh installed -consumers. The core and WebSocket guarantees of 0.6.0 are unchanged. TypeScript -ships as the release tarball with SHA256SUMS; Go ships through the root tag. +This is a coordinated source/dependency cutover. It does not deploy existing +services or add Function, Stream or Cell semantics to the runtime. diff --git a/go.mod b/go.mod index 995a648..15b117b 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,9 @@ module github.com/Bitspark/bitruntime go 1.26.0 require ( - github.com/Bitspark/bitwire v0.6.0 + github.com/Bitspark/bitwire v0.7.0 github.com/bitspark/deixis v0.6.0 + github.com/bitspark/ontos v0.16.0 + github.com/bitspark/ontos/wire/go v0.16.0 github.com/coder/websocket v1.8.15 ) diff --git a/go.sum b/go.sum index a417cb1..a08c783 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,10 @@ -github.com/Bitspark/bitwire v0.6.0 h1:Da4R/tRW+hw615DrsaPJ2KwFz0s/kagKdgN9nXfOf1s= -github.com/Bitspark/bitwire v0.6.0/go.mod h1:RCsIrMm1o0hg/SlyG2LkXXSzj2CMLEhoOIuuw8XrePk= +github.com/Bitspark/bitwire v0.7.0 h1:5VnpAiiQ9SoyGra87O+/r9huTkm+Vy/VVyGCbCUm7to= +github.com/Bitspark/bitwire v0.7.0/go.mod h1:WedbikTlAIMhqnP7ALzbusHYwV1HRjK+w11MpCd8S8k= github.com/bitspark/deixis v0.6.0 h1:YAbZiEB+wlQtZoTwLd2+3xGagsfVqmOEH0Fh+fzzaOA= github.com/bitspark/deixis v0.6.0/go.mod h1:jw08wxGevbjoJPBnUaDX549ayvjIOOlLk5GXhIkxu5A= +github.com/bitspark/ontos v0.16.0 h1:/LA9+ukd9+/WgIWLShUwlTB06bfpqEo43t9CGh9umgY= +github.com/bitspark/ontos v0.16.0/go.mod h1:GLOg9USEPJXJ7RN7iiOJ7OVlyM8b3X4lN0ZVTg2G3QY= +github.com/bitspark/ontos/wire/go v0.16.0 h1:yxuAMqLzizIALYlM1gryR76xfSDn9gFqRZKuWZPABWc= +github.com/bitspark/ontos/wire/go v0.16.0/go.mod h1:SsVBydSV21ifocddxxKuyZ7zZ21F5OPV2Vot74YM3GI= github.com/coder/websocket v1.8.15 h1:6B2JPeOGlpff2Uz6vOEH1Vzpi0iUz20A+lPVhPHtNUA= github.com/coder/websocket v1.8.15/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg= diff --git a/hydrated/README.md b/hydrated/README.md index 9577d70..4f1ba36 100644 --- a/hydrated/README.md +++ b/hydrated/README.md @@ -1,12 +1,13 @@ # Hydrated wires -**Status, 7 October 2026:** the realization of bitwire decision 0019, the hydrated +**Status, 4 November 2026:** the realization of bitwire decision 0019, the hydrated wire protocol's first edition, accepted at bitwire `5b1de82`, for bitruntime -0.7.1 (first implemented in 0.7.0). It implements bitwire 0.6.0's public hydrated +0.8.0 (first implemented in 0.7.0). It implements bitwire 0.7.0's public hydrated declarations (`HydratedValue`, `HydratedWire`, `HydratedEndpoint`, `ReceivedContext`) and encodes and decodes through bitwire's shared pure hydrated codec, which owns the -grammar and its bounds. No private copy of either remains here. +grammar and its bounds. No private copy of either remains here. The shared native +value structure now comes from ontos/wire; see [the migration contract](../docs/ONTOS-WIRE.md). [The Go package](go/hydrated.go) and [the TypeScript module](ts/src/index.ts) hold the stateful half of the protocol: diff --git a/hydrated/go/hydrated.go b/hydrated/go/hydrated.go index 5cc861a..5b334eb 100644 --- a/hydrated/go/hydrated.go +++ b/hydrated/go/hydrated.go @@ -16,8 +16,9 @@ import ( "strconv" "sync" - ontos "github.com/Bitspark/bitwire/ontos/go/core" wire "github.com/Bitspark/bitwire/wire/go" + ontos "github.com/bitspark/ontos/core/go" + ontoswire "github.com/bitspark/ontos/wire/go" ) // The runtime realizes bitwire's public hydrated declarations. @@ -25,7 +26,6 @@ var ( _ wire.HydratedEndpoint = (*Endpoint)(nil) _ wire.HydratedWire = (*face)(nil) _ wire.HydratedWire = (*proxy)(nil) - _ wire.HydratedTuple = Tuple{} ) // Local is the context of a send that never left the process. @@ -48,70 +48,36 @@ const ( ScopeEnded Refusal = "scope-ended" ) -// Tuple is a hydrated tuple with at least one wire.HydratedWire beneath it. NewTuple returns -// the ground tuple when there is none (D1). -type Tuple struct{ items []wire.HydratedValue } - -// NewTuple captures items. Each must be an ontos value, a Tuple or a wire.HydratedWire. An -// Endpoint is captured as its sending face: a value never carries receive or -// close authority, on any path (D7). -func NewTuple(items ...wire.HydratedValue) (wire.HydratedValue, error) { - captured := make([]wire.HydratedValue, len(items)) - for i, item := range items { - captured[i] = sendOnly(item) - } - ground := make([]ontos.Value, 0, len(captured)) - live := false - for _, item := range captured { - switch x := item.(type) { - case ontos.Atom: - ground = append(ground, x) - case ontos.Tuple: - ground = append(ground, x) - case Tuple, *face, *proxy: - live = true - case wire.HydratedWire: - return nil, Unexportable // only the runtime's own Wires are leaves (D1) - default: - return nil, errors.New("hydrated: not a value") - } - } - if live { - return Tuple{captured}, nil - } - return ontos.NewTuple(ground...), nil -} - -// sendOnly projects an Endpoint to its sending face, and the zero Tuple, the -// only one NewTuple does not make, to the ground empty tuple (D1, D7). -func sendOnly(v wire.HydratedValue) wire.HydratedValue { - switch x := v.(type) { +// nativeValues owns only the runtime's leaf policy. Immutable tuple storage, +// ground collapse and factory qualification belong to ontos/wire. +var nativeValues = ontoswire.NewNativeFactory(func(value any) (wire.HydratedWire, error) { + switch v := value.(type) { case *Endpoint: - return x.face - case Tuple: - if x.items == nil { - return ontos.NewTuple() + if v != nil { + return v.face, nil } + case *face: + if v != nil { + return v, nil + } + case *proxy: + if v != nil { + return v, nil + } + case wire.HydratedWire: + return nil, Unexportable } - return v -} + return nil, errors.New("hydrated: not a value") +}) -// Items returns the tuple's items. -func (t Tuple) Items() []wire.HydratedValue { return append([]wire.HydratedValue(nil), t.items...) } +// NewTuple captures immediate children under the runtime's sending-face policy. +func NewTuple(items ...wire.HydratedValue) (wire.HydratedValue, error) { + return nativeValues.Tuple(items...) +} -// Items returns any tuple's items, ground or hydrated. +// Items observes any tuple's immutable children; it confers no authority. func Items(v wire.HydratedValue) ([]wire.HydratedValue, bool) { - switch x := v.(type) { - case Tuple: - return x.Items(), true - case ontos.Tuple: - out := make([]wire.HydratedValue, x.Len()) - for i, item := range x.Items() { - out[i] = item - } - return out, true - } - return nil, false + return ontoswire.NativeItems[wire.HydratedWire](v) } // Namespace identifies one set of participants addressed by absolute paths. @@ -185,26 +151,13 @@ type delivery struct { type face struct{ e *Endpoint } func (f *face) Send(v wire.HydratedValue) error { - projected := sendOnly(v) - if err := checkLocal(projected); err != nil { + projected, err := nativeValues.Capture(v) + if err != nil { return err } return f.e.admit(projected, Local{}) } -// checkLocal validates a value for local delivery as dehydration would for a -// remote one (D1, D7). A Tuple recognized its leaves when NewTuple built it and -// is immutable, so only the top level needs checking; nothing is traversed. -func checkLocal(v wire.HydratedValue) error { - switch v.(type) { - case ontos.Atom, ontos.Tuple, Tuple, *face, *proxy: - return nil - case wire.HydratedWire: - return Unexportable - } - return errors.New("hydrated: not a value") -} - // NewEndpoint creates an endpoint whose queue admits at most limit values. A // bound below one is a programming error. func NewEndpoint(limit int) *Endpoint { @@ -563,6 +516,10 @@ func (s *Scope) send(dest Reference, v wire.HydratedValue) error { } func (s *Scope) stage(dest Reference, v wire.HydratedValue) (ontos.Value, error) { + v, err := nativeValues.Capture(v) + if err != nil { + return nil, err + } s.encodeMu.Lock() defer s.encodeMu.Unlock() staged := map[*Endpoint]ontos.Atom{} @@ -648,7 +605,7 @@ func (s *Scope) toData(v wire.HydratedValue, depth int, staged map[*Endpoint]ont return nil, err } return wire.NewHydratedDataAtom(x), nil - case ontos.Tuple, Tuple: + case ontos.Tuple, ontoswire.NativeTuple[wire.HydratedWire]: if err := s.spend(b, depth, 0); err != nil { return nil, err } @@ -691,8 +648,8 @@ func tupleIndex(v wire.HydratedValue) (int, func(int) wire.HydratedValue) { switch x := v.(type) { case ontos.Tuple: return x.Len(), func(i int) wire.HydratedValue { return x.At(i) } - case Tuple: - return len(x.items), func(i int) wire.HydratedValue { return x.items[i] } + case ontoswire.NativeTuple[wire.HydratedWire]: + return x.Len(), x.At } return 0, nil } @@ -721,6 +678,10 @@ func (s *Scope) fromData(d wire.HydratedData, interned map[string]wire.HydratedW // encodeBody and decodeBody are the body halves of a frame. func (s *Scope) encodeBody(v wire.HydratedValue, staged map[*Endpoint]ontos.Atom) (ontos.Value, error) { + v, err := nativeValues.Capture(v) + if err != nil { + return nil, err + } d, err := s.toData(v, 0, staged, &budget{}) if err != nil { return nil, err diff --git a/hydrated/go/hydrated_test.go b/hydrated/go/hydrated_test.go index 0e416ef..103c8a3 100644 --- a/hydrated/go/hydrated_test.go +++ b/hydrated/go/hydrated_test.go @@ -17,12 +17,41 @@ import ( core "github.com/Bitspark/bitruntime/core/go" websocket "github.com/Bitspark/bitruntime/websocket/go" - ontos "github.com/Bitspark/bitwire/ontos/go/core" wire "github.com/Bitspark/bitwire/wire/go" + ontos "github.com/bitspark/ontos/core/go" + ontoswire "github.com/bitspark/ontos/wire/go" ) func text(s string) ontos.Atom { return ontos.NewAtom([]byte(s)) } +func TestSharedNativeFactoryCannotConcealOwnership(t *testing.T) { + endpoint, owner := NewEndpoint(1), NewEndpoint(1) + defer endpoint.Close() + defer owner.Close() + foreign := ontoswire.NewNativeFactory(func(value any) (wire.HydratedWire, error) { + return value.(wire.HydratedWire), nil + }) + concealed, err := foreign.Tuple(owner) + if err != nil { + t.Fatal(err) + } + if err := endpoint.Wire().Send(concealed); !errors.Is(err, ontoswire.ErrNativeValue) { + t.Fatal("foreign qualification bypassed local admission", err) + } + scope := &Scope{limits: DefaultLimits} + if _, err := scope.encodeBody(concealed, map[*Endpoint]ontos.Atom{}); !errors.Is(err, ontoswire.ErrNativeValue) { + t.Fatal("foreign qualification bypassed export admission", err) + } + qualified, err := NewTuple(owner) + if err != nil { + t.Fatal(err) + } + items, _ := Items(qualified) + if items[0] != owner.Wire() { + t.Fatal("owner was not projected to its sending face") + } +} + // The raw grammar, for crafting frames by hand; the runtime itself uses the codec. var ( header = ontos.NewAtom([]byte("bitwire/hydrated/1")) @@ -99,9 +128,9 @@ func wires(v wire.HydratedValue) int { switch x := v.(type) { case wire.HydratedWire: return 1 - case Tuple: + case ontoswire.NativeTuple[wire.HydratedWire]: n := 0 - for _, item := range x.items { + for _, item := range x.Items() { n += wires(item) } return n @@ -1031,7 +1060,7 @@ func TestObservation17ZeroTupleIsGround(t *testing.T) { got := make(chan wire.HydratedValue, 1) local := NewEndpoint(1) _, _ = local.Receive(func(v wire.HydratedValue, _ wire.ReceivedContext) { got <- v }) - _ = local.Wire().Send(Tuple{}) + _ = local.Wire().Send(ontoswire.NativeTuple[wire.HydratedWire]{}) if v, ok := (<-got).(ontos.Tuple); !ok || v.Len() != 0 { t.Fatal("the zero hydrated tuple was not delivered as the ground empty tuple") } diff --git a/hydrated/ts/src/index.ts b/hydrated/ts/src/index.ts index 63f7dd6..97efbaf 100644 --- a/hydrated/ts/src/index.ts +++ b/hydrated/ts/src/index.ts @@ -1,16 +1,13 @@ +import { NativeFactory, NativeTuple, nativeItems } from '@bitspark/ontos-wire/native'; // The realization of bitwire decision 0019, the hydrated wire protocol's first // edition, over bitwire's public hydrated declarations and its shared pure codec. // The codec owns the grammar, validation and bounds; this module owns export ids // and staging, reference recognition, liveness and endpoints. -import { - Atom, Tuple, atom, tuple, pathEqual, - HydratedCodecError, HydratedDataAtom, HydratedDataTuple, HydratedReference, - packHydratedBody, unpackHydratedBody, packHydratedFrame, unpackHydratedFrame, - packHydratedReference, unpackHydratedReference, -} from '@bitspark/bitwire'; +import { Atom, Tuple, atom, tuple } from '@bitspark/ontos-core'; +import { pathEqual, HydratedCodecError, HydratedDataAtom, HydratedDataTuple, HydratedReference, packHydratedBody, unpackHydratedBody, packHydratedFrame, unpackHydratedFrame, packHydratedReference, unpackHydratedReference } from '@bitspark/bitwire'; import type { Path, AddressedWire, Termination, HydratedValue, HydratedWire, HydratedEndpoint, ReceivedContext, - HydratedData, HydratedCodecLimits, HydratedTuple as HydratedTupleView, + HydratedData, HydratedCodecLimits, } from '@bitspark/bitwire'; /** The context of a send that never left the process. */ @@ -34,64 +31,33 @@ export class Refusal extends Error { } } -/** A tuple with at least one HydratedWire beneath it; see hydratedTuple (D1). */ -/** Only this module constructs hydrated tuples, so every one is canonical (D1, D7). */ -const CONSTRUCT = Symbol('hydrated tuple'); - -/** - * A tuple with at least one HydratedWire beneath it, shaped like bitwire's HydratedTuple - * (a ground Tuple has the same shape). Construct it with hydratedTuple(). - */ -export class HydratedTuple implements HydratedTupleView { - readonly kind = 'tuple' as const; - readonly #items: readonly HydratedValue[]; - constructor(items: readonly HydratedValue[], token?: symbol) { - if (token !== CONSTRUCT) throw new TypeError('hydrated: construct tuples with hydratedTuple()'); - this.#items = Object.freeze([...items]); - Object.freeze(this); +// The private factory supplies recognition/attenuation, never structure or +// liveness. A tuple made by any other policy cannot bypass this qualification. +const endpointFaces = new WeakMap(); +const proxies = new WeakSet(); +const nativeValues = new NativeFactory((value: unknown) => { + if (value instanceof Endpoint) { + const face = endpointFaces.get(value); + if (!face) throw new Refusal(UNEXPORTABLE); + return face; } - get length(): number { return this.#items.length; } - items(): readonly HydratedValue[] { return this.#items; } - at(index: number): HydratedValue | undefined { return this.#items.at(index); } -} - -// Any HydratedWire may sit in a tuple; encoding refuses one the runtime does not own (D7). -const isWire = (v: unknown): v is HydratedWire => typeof (v as HydratedWire | undefined)?.send === 'function'; - -/** An Endpoint travels only as its sending face, on every path (D7). */ -const sendOnly = (v: HydratedValue): HydratedValue => (v instanceof Endpoint ? v.wire : v); - -/** - * Validates a value for local delivery as dehydration would for a remote one (D1, - * D7): only runtime-recognized leaves arrive, and an endpoint arrives as its face. - */ -function local(v: HydratedValue): HydratedValue { - // A tuple recognized its leaves when it was built and is immutable, so only - // the top level needs checking; no traversal is needed. - const projected = sendOnly(v); - if (projected instanceof Atom || projected instanceof Tuple || projected instanceof HydratedTuple) return projected; - if (projected instanceof Face || projected instanceof Proxy) return projected; - if (projected && typeof (projected as HydratedWire).send === 'function') throw new Refusal(UNEXPORTABLE); + if (value instanceof Face && owners.has(value)) return value; + if (value instanceof Proxy && proxies.has(value)) return value; + if (value && typeof (value as HydratedWire).send === 'function') throw new Refusal(UNEXPORTABLE); throw new TypeError('hydrated: not a value'); -} +}); + +/** Shallow qualification preserves local identity without unfolding shared trees. */ +const local = (value: HydratedValue): HydratedValue => nativeValues.capture(value); -/** Captures items; returns the ground tuple when no HydratedWire is beneath them. */ +/** Captures immediate children and projects owners to their sending faces. */ export function hydratedTuple(items: readonly HydratedValue[]): HydratedValue { - const captured = items.map(sendOnly); - let live = false; - for (const item of captured) { - if (item instanceof HydratedTuple || item instanceof Face || item instanceof Proxy) live = true; - else if (isWire(item)) throw new Refusal(UNEXPORTABLE); // only the runtime's own Wires are leaves (D1) - else if (!(item instanceof Atom) && !(item instanceof Tuple)) throw new TypeError('hydrated: not a value'); - } - return live ? new HydratedTuple(captured, CONSTRUCT) : tuple(captured as (Atom | Tuple)[]); + return nativeValues.tuple(items); } -/** Any tuple's items, ground or hydrated. */ -export function items(v: HydratedValue): readonly HydratedValue[] | undefined { - if (v instanceof HydratedTuple) return v.items(); - if (v instanceof Tuple) return v.items(); - return undefined; +/** Observes immutable tuple structure; does not establish runtime authority. */ +export function items(value: HydratedValue): readonly HydratedValue[] | undefined { + return nativeItems(value); } /** One set of participants addressed by absolute paths (D6). */ @@ -146,10 +112,11 @@ export class Endpoint implements HydratedEndpoint { if (!Number.isSafeInteger(limit) || limit < 1) throw new RangeError('hydrated: an endpoint bound must be a positive integer'); this.#limit = limit; this.wire = new Face(this); + endpointFaces.set(this, this.wire as Face); this.closed = new Promise((resolve) => { this.#resolveClosed = resolve; }); } - send(value: HydratedValue): Promise { return this.wire.send(value); } + send(value: HydratedValue): Promise { return endpointFaces.get(this)!.send(value); } /** Attaches the one receiver; its detach removes only that receiver. */ receive(handler: (value: HydratedValue, context: ReceivedContext) => void): () => void { @@ -238,6 +205,7 @@ class Proxy implements HydratedWire { readonly #dead: string | undefined; constructor(ref: Reference, ns: Namespace, via: Scope, dead?: string) { this.ref = ref; this.ns = ns; this.#via = via; this.#dead = dead; + proxies.add(this); Object.freeze(this); } async send(value: HydratedValue): Promise { @@ -365,11 +333,11 @@ export class Scope { if (nodes > limits.nodes || depth > limits.depth || bytes > limits.bytes) throw new Refusal(LIMIT); }; // Tuples are indexed, never copied; outputs grow as children are counted. - const frames: { tuple: Tuple | HydratedTuple; depth: number; out: HydratedData[] }[] = []; + const frames: { tuple: Tuple | NativeTuple; depth: number; out: HydratedData[] }[] = []; const visit = (value: HydratedValue, depth: number): HydratedData | undefined => { - const v = value instanceof Endpoint ? value.wire : value; + const v = local(value); if (v instanceof Atom) { spend(depth, v.length); return new HydratedDataAtom(v); } - if (v instanceof Tuple || v instanceof HydratedTuple) { + if (v instanceof Tuple || v instanceof NativeTuple) { spend(depth, 0); frames.push({ tuple: v, depth, out: [] }); return undefined; @@ -386,7 +354,7 @@ export class Scope { if (v && typeof (v as HydratedWire).send === 'function') throw new Refusal(UNEXPORTABLE); throw new TypeError('hydrated: not a value'); }; - const first = visit(root, 0); + const first = visit(local(root), 0); if (first) return first; for (;;) { const top = frames[frames.length - 1]!; @@ -450,7 +418,7 @@ export class Scope { if (pathEqual(ref.path, this.path)) { if (!ref.scope.equals(this.token)) return new Proxy(ref, this.ns, this, STALE_SCOPE); const endpoint = this.#byId.get(hex(ref.id)); - return endpoint ? endpoint.wire : new Proxy(ref, this.ns, this, UNKNOWN_EXPORT); + return endpoint ? endpointFaces.get(endpoint)! : new Proxy(ref, this.ns, this, UNKNOWN_EXPORT); } const k = refKey(ref); let w = interned.get(k); diff --git a/hydrated/ts/test/fixtures/domain.mjs b/hydrated/ts/test/fixtures/domain.mjs index 0b8b320..98f2b84 100644 --- a/hydrated/ts/test/fixtures/domain.mjs +++ b/hydrated/ts/test/fixtures/domain.mjs @@ -1,5 +1,5 @@ // Consumer-only request and ownership convention. No Scope, route or reference API. -import { Atom, atom } from '@bitspark/bitwire'; +import { Atom, atom } from '@bitspark/ontos-core'; import { Endpoint, hydratedTuple, items } from '../../../../dist/hydrated/ts/src/index.js'; export const text = value => atom(new TextEncoder().encode(value)); diff --git a/hydrated/ts/test/harness.mjs b/hydrated/ts/test/harness.mjs index 22130df..235e14a 100644 --- a/hydrated/ts/test/harness.mjs +++ b/hydrated/ts/test/harness.mjs @@ -3,7 +3,7 @@ // routes and ground values, over local pairs or real WebSockets. Consumer suites // import it rather than editing hydrated.test.mjs. import assert from 'node:assert/strict'; -import { atom } from '@bitspark/bitwire'; +import { atom } from '@bitspark/ontos-core'; import { pair, addressed } from '../../../dist/core/ts/src/index.js'; import { listenWebSocket, connectWebSocket } from '../../../dist/websocket/ts/src/index.js'; import { Endpoint, Namespace, Scope, hydratedTuple } from '../../../dist/hydrated/ts/src/index.js'; diff --git a/hydrated/ts/test/hydrated.test.mjs b/hydrated/ts/test/hydrated.test.mjs index 1ae4ae8..8634270 100644 --- a/hydrated/ts/test/hydrated.test.mjs +++ b/hydrated/ts/test/hydrated.test.mjs @@ -4,12 +4,69 @@ import { test } from 'node:test'; import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { createHash } from 'node:crypto'; -import { Atom, Tuple, atom, tuple, encodeMessage } from '@bitspark/bitwire'; +import { Atom, Tuple, atom, tuple } from '@bitspark/ontos-core'; +import { encodeMessage } from '@bitspark/bitwire'; import { Endpoint, Namespace, Scope, Refusal, hydratedTuple, items, UNKNOWN_EXPORT, STALE_SCOPE, UNEXPORTABLE, FOREIGN_NAMESPACE, MALFORMED_FRAME, } from '../../../dist/hydrated/ts/src/index.js'; import { text, str, eventually, PATHS, tree, serve, call } from './harness.mjs'; +import { NativeFactory, NativeValueError } from '@bitspark/ontos-wire/native'; + +test('qualification uses private endpoint faces and genuine capability instances', async () => { + const endpoint = new Endpoint(4), owner = new Endpoint(1); + const face = owner.wire; + const foreign = { kind: 'wire', send: async () => {}, close() {} }; + owner.wire = foreign; + const received = []; + endpoint.receive(v => received.push(v)); + await endpoint.wire.send(owner); + await endpoint.wire.send(hydratedTuple([owner])); + await eventually(() => received.length === 2, 'qualified values not delivered'); + assert.equal(received[0], face); + assert.equal(items(received[1])[0], face); + assert.equal('close' in face, false); + const scope = new Scope(new Namespace('private-membership'), [], { send: async () => {} }); + const proxy = scope.connect({ path: [text('remote')], scope: atom(new Uint8Array(16)), id: atom(new Uint8Array(16)) }); + const fakeOwner = Object.assign(Object.create(Endpoint.prototype), { wire: foreign }); + const fakes = [fakeOwner, Object.create(Object.getPrototypeOf(face)), Object.create(Object.getPrototypeOf(proxy))]; + for (const fake of fakes) { + await assert.rejects(endpoint.wire.send(fake), e => e.reason === UNEXPORTABLE); + assert.throws(() => hydratedTuple([fake]), e => e.reason === UNEXPORTABLE); + assert.throws(() => scope._encodeBody(fake, new Map()), e => e.reason === UNEXPORTABLE); + } + const staged = new Map(); + scope._encodeBody(hydratedTuple([owner]), staged); + assert.equal(staged.size, 1); + assert.equal(staged.has(owner), true); + const home = scope.expose(owner); + assert.equal(scope.connect(home), face, 'a local reference recovers the stable sending face'); + const body = scope._encodeBody(owner, new Map()); + assert.equal(scope._decodeBody(body, new Map()), face, 'a returning-home leaf recovers the stable sending face'); + scope.close(); + await endpoint.close(); + await owner.close(); +}); + +test('shared native tuples require this runtime factory on local and remote paths', async () => { + const endpoint = new Endpoint(2), owner = new Endpoint(2); + const foreign = new NativeFactory(value => value); + const concealed = foreign.tuple([owner]); + let received = false; + endpoint.receive(() => { received = true; }); + await assert.rejects(endpoint.wire.send(concealed), NativeValueError); + const scope = new Scope(new Namespace('foreign-native'), [], { send: async () => { throw new Error('must not send'); } }); + assert.throws(() => scope._encodeBody(concealed, new Map()), NativeValueError); + const hostile = [owner]; + hostile.map = () => [{ send() {}, close() {} }]; + const captured = hydratedTuple(hostile); + assert.equal(items(captured)[0], owner.wire); + assert.equal('close' in items(captured)[0], false); + assert.equal(received, false); + scope.close(); + await endpoint.close(); + await owner.close(); +}); test('observation 1: vectors round-trip (bitwire#83 accepted at 6e33fb3, pinned)', () => { const raw = readFileSync(new URL('../../go/testdata/hydrated-vectors.json', import.meta.url)); @@ -283,10 +340,10 @@ test('observation 15, symmetry: sender and receiver count a value alike', async }); test('observation 17, construction: the exported tuple class cannot bypass projection', async () => { - const { HydratedTuple } = await import('../../../dist/hydrated/ts/src/index.js'); + const { NativeTuple } = await import('@bitspark/ontos-wire/native'); const priv = new Endpoint(1); - assert.throws(() => new HydratedTuple([priv]), /hydratedTuple/); - assert.throws(() => new HydratedTuple([text('ground')]), /hydratedTuple/); + assert.throws(() => new NativeTuple(Symbol(), {}, [priv]), /NativeFactory/); + assert.throws(() => new NativeTuple(Symbol(), {}, [text('ground')]), /NativeFactory/); const got = []; const local = new Endpoint(4); local.receive((v) => got.push(v)); diff --git a/package-lock.json b/package-lock.json index 214c26c..8eef1d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,17 @@ { "name": "@bitspark/bitruntime", - "version": "0.7.1", + "version": "0.8.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@bitspark/bitruntime", - "version": "0.7.1", + "version": "0.8.0", "license": "Apache-2.0", "dependencies": { - "@bitspark/bitwire": "0.6.0", + "@bitspark/bitwire": "0.7.0", + "@bitspark/ontos-core": "0.16.0", + "@bitspark/ontos-wire": "0.16.0", "ws": "8.22.0" }, "devDependencies": { @@ -23,18 +25,54 @@ } }, "node_modules/@bitspark/bitwire": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@bitspark/bitwire/-/bitwire-0.6.0.tgz", - "integrity": "sha512-rWkRP9I4Thej53yZpyKYIHr98RPcYPRrYSjnB0yWRfCn1s2vFJ1xGro2fGwOVUldR6+vZuK87brOMYOKyQFNNw==", - "license": "Apache-2.0" + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@bitspark/bitwire/-/bitwire-0.7.0.tgz", + "integrity": "sha512-hwwfY7bEWdlxX/L4d7FoRqnqErNuwEAqWW4T0nX0a7FpkgiuNZNH6gF28kVaZdACSUtARY5BEbDFayg20llDow==", + "license": "Apache-2.0", + "dependencies": { + "@bitspark/ontos-codec": "0.16.0", + "@bitspark/ontos-core": "0.16.0", + "@bitspark/ontos-wire": "0.16.0" + } }, "node_modules/@bitspark/deixis-core": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/@bitspark/deixis-core/-/deixis-core-0.6.0.tgz", "integrity": "sha512-NozhLN14Pa7F8SwBRuZ8uwVp50S1h1DHhG0F/bnU3pUVE60A4HJisHaAxFaMDbDY3KGfLHbeEzxlUAK8s/QEWg==", - "dev": true, "license": "Apache-2.0" }, + "node_modules/@bitspark/deixis-pos": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@bitspark/deixis-pos/-/deixis-pos-0.6.0.tgz", + "integrity": "sha512-cHHaGfeVhV2WY94696LbmQAu5iKwLZ14brkZbRO1ZGCQgNYQZEIDe32RkcFu0TmMmX5R0MzYDHFtomDvX+x0Gw==", + "license": "Apache-2.0" + }, + "node_modules/@bitspark/ontos-codec": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/@bitspark/ontos-codec/-/ontos-codec-0.16.0.tgz", + "integrity": "sha512-IwKFL4nrBRFfdlzCxu2i7nPHO+3+HHoqcgU6yyt5gYnq2BoPjr9vo8j4cuElJtfotGCAfh3L2xR8VMjDEdKXyg==", + "license": "Apache-2.0", + "dependencies": { + "@bitspark/ontos-core": "^0.16.0" + } + }, + "node_modules/@bitspark/ontos-core": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/@bitspark/ontos-core/-/ontos-core-0.16.0.tgz", + "integrity": "sha512-23AlUWmQMwZrKNaneMKnepzLViRM+PiSbgkY4ycjqELvj2ibO7HQLNIwKS7xpRmTbjoU2UCuOiGa/MLwRSIEog==", + "license": "Apache-2.0" + }, + "node_modules/@bitspark/ontos-wire": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/@bitspark/ontos-wire/-/ontos-wire-0.16.0.tgz", + "integrity": "sha512-0mbjbl1Lw5gdxw8iFxebRzrcAQde/vZZ0XWIjhgFi+zNHfXdaCQmIES1DUk83+nK3McwH+n4cfQv3PduoRncKA==", + "license": "Apache-2.0", + "dependencies": { + "@bitspark/deixis-core": "0.6.0", + "@bitspark/deixis-pos": "0.6.0", + "@bitspark/ontos-core": "^0.16.0" + } + }, "node_modules/@types/node": { "version": "24.19.0", "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.0.tgz", diff --git a/package.json b/package.json index 98adb29..968d727 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bitspark/bitruntime", - "version": "0.7.1", + "version": "0.8.0", "description": "Addressless endpoints, addressed access, byte-keyed trees, local pairs and WebSocket carriers.", "license": "Apache-2.0", "type": "module", @@ -39,8 +39,10 @@ "test": "npm run build && node --test --test-timeout=30000 \"core/ts/test/*.test.mjs\" \"websocket/ts/test/*.test.mjs\" \"hydrated/ts/test/*.test.mjs\"" }, "dependencies": { - "@bitspark/bitwire": "0.6.0", - "ws": "8.22.0" + "@bitspark/bitwire": "0.7.0", + "ws": "8.22.0", + "@bitspark/ontos-core": "0.16.0", + "@bitspark/ontos-wire": "0.16.0" }, "devDependencies": { "@bitspark/deixis-core": "0.6.0", diff --git a/scripts/hydrated-interop.mjs b/scripts/hydrated-interop.mjs index 19f1752..ae5325b 100644 --- a/scripts/hydrated-interop.mjs +++ b/scripts/hydrated-interop.mjs @@ -8,7 +8,8 @@ import { mkdtempSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { createInterface } from 'node:readline'; -import { atom, pathEqual } from '@bitspark/bitwire'; +import { atom } from '@bitspark/ontos-core'; +import { pathEqual } from '@bitspark/bitwire'; import { addressed } from '../dist/core/ts/src/index.js'; import { connectWebSocket, listenWebSocket } from '../dist/websocket/ts/src/index.js'; import { Endpoint, Namespace, Scope, hydratedTuple, items, readReference, referenceValue } from '../dist/hydrated/ts/src/index.js'; diff --git a/scripts/interop.mjs b/scripts/interop.mjs index 31cf95d..a0d255a 100644 --- a/scripts/interop.mjs +++ b/scripts/interop.mjs @@ -4,7 +4,8 @@ import {mkdtempSync} from 'node:fs'; import {tmpdir} from 'node:os'; import {join} from 'node:path'; import {createInterface} from 'node:readline'; -import {atom,tuple,pathEqual} from '@bitspark/bitwire'; +import { atom, tuple } from '@bitspark/ontos-core'; +import { pathEqual } from '@bitspark/bitwire'; import {addressed} from '../dist/core/ts/src/index.js'; import {connectWebSocket,listenWebSocket} from '../dist/websocket/ts/src/index.js'; const directory=mkdtempSync(join(tmpdir(),'bitruntime-interop-')); diff --git a/scripts/package-smoke.mjs b/scripts/package-smoke.mjs index e7852de..564dca2 100644 --- a/scripts/package-smoke.mjs +++ b/scripts/package-smoke.mjs @@ -39,7 +39,8 @@ writeFileSync(join(temp, 'package.json'), '{"type":"module","private":true}\n'); run(npm, ['install', '--ignore-scripts', '--no-audit', '--@bitspark:registry=https://registry.npmjs.org', join(temp, packed[0].filename)], temp); writeFileSync(join(temp, 'smoke.mjs'), ` import assert from 'node:assert/strict'; -import {atom,tuple,pathEqual} from '@bitspark/bitwire'; +import { atom, tuple } from '@bitspark/ontos-core'; +import { pathEqual } from '@bitspark/bitwire'; import {pair,compose,addressed,bind,asAddressed} from '@bitspark/bitruntime/core'; import {connectWebSocket,listenWebSocket} from '@bitspark/bitruntime/websocket'; import {Endpoint,Namespace,Scope,hydratedTuple,items} from '@bitspark/bitruntime/hydrated'; diff --git a/websocket/go/wire.go b/websocket/go/wire.go index 4e97d2d..2c515c1 100644 --- a/websocket/go/wire.go +++ b/websocket/go/wire.go @@ -4,7 +4,7 @@ package websocket import ( "context" "errors" - ontos "github.com/Bitspark/bitwire/ontos/go/core" + ontos "github.com/bitspark/ontos/core/go" "io" "sync" "time" diff --git a/websocket/go/wire_test.go b/websocket/go/wire_test.go index 7036b66..0ffe36a 100644 --- a/websocket/go/wire_test.go +++ b/websocket/go/wire_test.go @@ -5,8 +5,8 @@ import ( "encoding/hex" core "github.com/Bitspark/bitruntime/core/go" ws "github.com/Bitspark/bitruntime/websocket/go" - ontos "github.com/Bitspark/bitwire/ontos/go/core" wire "github.com/Bitspark/bitwire/wire/go" + ontos "github.com/bitspark/ontos/core/go" carrier "github.com/coder/websocket" "net/http" "net/http/httptest" diff --git a/websocket/ts/src/endpoint.ts b/websocket/ts/src/endpoint.ts index 2f8d269..387cca2 100644 --- a/websocket/ts/src/endpoint.ts +++ b/websocket/ts/src/endpoint.ts @@ -1,7 +1,8 @@ // A single WebSocket endpoint realizing the generic Endpoint lifecycle. import WebSocket from 'ws'; import type { RawData } from 'ws'; -import type { Value, Endpoint, Termination } from '@bitspark/bitwire'; +import type { Value } from '@bitspark/ontos-core'; +import type { Endpoint, Termination } from '@bitspark/bitwire'; import type { WebSocketEndpointOptions } from './options.ts'; import { encodeMessage, decodeMessage, DEFAULT_MAX_MESSAGE_BYTES } from '@bitspark/bitwire'; import { positiveLimit } from '../../../core/ts/src/limits.ts'; diff --git a/websocket/ts/test/carrier.test.mjs b/websocket/ts/test/carrier.test.mjs index 96c4762..3a7263f 100644 --- a/websocket/ts/test/carrier.test.mjs +++ b/websocket/ts/test/carrier.test.mjs @@ -5,7 +5,8 @@ import {createServer} from 'node:http'; import {createServer as createHttpsServer} from 'node:https'; import {readFileSync} from 'node:fs'; import WebSocket from 'ws'; -import {atom,tuple,encodeMessage,WEBSOCKET_PROTOCOL} from '@bitspark/bitwire'; +import { atom, tuple } from '@bitspark/ontos-core'; +import { encodeMessage, WEBSOCKET_PROTOCOL } from '@bitspark/bitwire'; import {checkAddressedEndpoints} from '@bitspark/bitwire/conformance'; import {addressed} from '../../../dist/core/ts/src/index.js'; import {connectWebSocket,listenWebSocket,bindWebSocketServer} from '../../../dist/websocket/ts/src/index.js';