statewire 0.21.2__tar.gz → 0.22.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {statewire-0.21.2 → statewire-0.22.0}/PKG-INFO +1 -1
- {statewire-0.21.2 → statewire-0.22.0}/pyproject.toml +1 -1
- {statewire-0.21.2 → statewire-0.22.0}/src/statewire/api.py +8 -0
- {statewire-0.21.2 → statewire-0.22.0}/src/statewire/client.py +5 -4
- {statewire-0.21.2 → statewire-0.22.0}/src/statewire/protocol.py +1 -1
- {statewire-0.21.2 → statewire-0.22.0}/tests/statewire_helpers.py +2 -2
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_context.py +2 -2
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_gap_fill.py +2 -2
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_lanes.py +2 -2
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_protocol_negotiation.py +46 -6
- {statewire-0.21.2 → statewire-0.22.0}/.gitignore +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/README.md +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/examples/__init__.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/examples/demo_app.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/src/statewire/__init__.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/src/statewire/document.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/src/statewire/documents.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/src/statewire/langgraph.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/src/statewire/limits.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/src/statewire/metrics.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/src/statewire/ops.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/src/statewire/state.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/src/statewire/testing.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/client_helpers.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/storage_probe.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_attach_guardrail.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_attached_hook.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_authorize.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_client.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_client_binding.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_client_ws.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_date_registry.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_departure.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_document.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_durable_admission.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_eviction.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_frames.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_idle.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_langgraph.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_lifespan.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_meta.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_observer.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_ops.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_route_auth.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_start_session.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_state_proxy.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_statewire_hostable.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_storage_bridge.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_stream.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_testing.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_writer_lease.py +0 -0
- {statewire-0.21.2 → statewire-0.22.0}/tests/test_ws.py +0 -0
|
@@ -1417,6 +1417,14 @@ class Statewire(PinnedAPI):
|
|
|
1417
1417
|
f"{cls.__name__}.max_inflight_commands must be a positive int: "
|
|
1418
1418
|
f"{cls.max_inflight_commands!r}"
|
|
1419
1419
|
)
|
|
1420
|
+
if (
|
|
1421
|
+
not isinstance(cls.wire_version, VersionRange)
|
|
1422
|
+
or cls.wire_version.version > WIRE_VERSION
|
|
1423
|
+
):
|
|
1424
|
+
raise ValueError(
|
|
1425
|
+
f"{cls.__name__}.wire_version must be a VersionRange no newer than "
|
|
1426
|
+
f"{WIRE_VERSION}: {cls.wire_version!r}"
|
|
1427
|
+
)
|
|
1420
1428
|
if cls.admission_record not in ("list", "envelope"):
|
|
1421
1429
|
raise ValueError(
|
|
1422
1430
|
f"{cls.__name__}.admission_record must be 'list' or 'envelope': "
|
|
@@ -20,6 +20,7 @@ from urllib.parse import quote, urlencode
|
|
|
20
20
|
import httpx
|
|
21
21
|
|
|
22
22
|
from .protocol import (
|
|
23
|
+
VERSION,
|
|
23
24
|
VersionRange,
|
|
24
25
|
Offer,
|
|
25
26
|
Selection,
|
|
@@ -532,12 +533,12 @@ class StatewireHttp:
|
|
|
532
533
|
application_protocols: tuple[Offer, ...] | str | None = None,
|
|
533
534
|
):
|
|
534
535
|
self.protocol = protocol
|
|
535
|
-
self.wire_version = wire_version or VersionRange()
|
|
536
|
+
self.wire_version = wire_version or VersionRange(VERSION)
|
|
536
537
|
self.application_protocols = (
|
|
537
538
|
None
|
|
538
539
|
if application_protocols == "*"
|
|
539
540
|
else (
|
|
540
|
-
(Offer(protocol, VersionRange()),)
|
|
541
|
+
(Offer(protocol, VersionRange(VERSION)),)
|
|
541
542
|
if application_protocols is None
|
|
542
543
|
else application_protocols
|
|
543
544
|
)
|
|
@@ -679,12 +680,12 @@ class StatewireWebsocket:
|
|
|
679
680
|
application_protocols: tuple[Offer, ...] | str | None = None,
|
|
680
681
|
):
|
|
681
682
|
self.protocol = protocol
|
|
682
|
-
self.wire_version = wire_version or VersionRange()
|
|
683
|
+
self.wire_version = wire_version or VersionRange(VERSION)
|
|
683
684
|
self.application_protocols = (
|
|
684
685
|
None
|
|
685
686
|
if application_protocols == "*"
|
|
686
687
|
else (
|
|
687
|
-
(Offer(protocol, VersionRange()),)
|
|
688
|
+
(Offer(protocol, VersionRange(VERSION)),)
|
|
688
689
|
if application_protocols is None
|
|
689
690
|
else application_protocols
|
|
690
691
|
)
|
|
@@ -8,9 +8,9 @@ from fastapi import FastAPI
|
|
|
8
8
|
from pinned import Lease, PinnedContext, PinnedHost, PinnedWorker, RealDomain
|
|
9
9
|
from statewire.api import CLIENT_ID_HEADER, LEASE_HEADER
|
|
10
10
|
from statewire.client import apply_ops as client_apply_ops
|
|
11
|
-
from statewire.protocol import headers as protocol_headers, VersionRange, Offer
|
|
11
|
+
from statewire.protocol import VERSION, headers as protocol_headers, VersionRange, Offer
|
|
12
12
|
|
|
13
|
-
NEGOTIATION = protocol_headers(VersionRange(), (Offer("default", VersionRange()),))
|
|
13
|
+
NEGOTIATION = protocol_headers(VersionRange(VERSION), (Offer("default", VersionRange(VERSION)),))
|
|
14
14
|
|
|
15
15
|
leases: dict[tuple[str, str], str] = {}
|
|
16
16
|
_AUTO = object()
|
|
@@ -236,9 +236,9 @@ async def test_preserved_socket_hello_reseeds_context_without_command_work():
|
|
|
236
236
|
|
|
237
237
|
class Transport:
|
|
238
238
|
def __init__(self):
|
|
239
|
-
from statewire.protocol import Offer, VersionRange
|
|
239
|
+
from statewire.protocol import VERSION, Offer, VersionRange
|
|
240
240
|
|
|
241
|
-
self._negotiation = (VersionRange(), (Offer("default", VersionRange()),))
|
|
241
|
+
self._negotiation = (VersionRange(VERSION), (Offer("default", VersionRange(VERSION)),))
|
|
242
242
|
self.incoming = asyncio.Queue()
|
|
243
243
|
self.frames = []
|
|
244
244
|
self.attached = None
|
|
@@ -15,9 +15,9 @@ from statewire_helpers import (
|
|
|
15
15
|
|
|
16
16
|
import statewire.api as api
|
|
17
17
|
from statewire import Statewire, command
|
|
18
|
-
from statewire.protocol import WIRE_VERSION, Offer, VersionRange, headers
|
|
18
|
+
from statewire.protocol import VERSION, WIRE_VERSION, Offer, VersionRange, headers
|
|
19
19
|
|
|
20
|
-
GAP_FILL = headers(VersionRange(WIRE_VERSION), (Offer("default", VersionRange()),))
|
|
20
|
+
GAP_FILL = headers(VersionRange(WIRE_VERSION), (Offer("default", VersionRange(VERSION)),))
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def make_host():
|
|
@@ -23,7 +23,7 @@ from statewire import (
|
|
|
23
23
|
)
|
|
24
24
|
from statewire.client import StatewireClient, Timing
|
|
25
25
|
from statewire.limits import MAX_EPHEMERAL_DOCUMENT_BYTES
|
|
26
|
-
from statewire.protocol import Offer, Protocol, VersionRange, validate_selection
|
|
26
|
+
from statewire.protocol import VERSION, Offer, Protocol, VersionRange, validate_selection
|
|
27
27
|
from statewire.testing import command_context
|
|
28
28
|
|
|
29
29
|
INTEREST = "default/interest"
|
|
@@ -414,7 +414,7 @@ async def test_client_selects_the_child_lane_and_resets_it_on_reattach(sse_clien
|
|
|
414
414
|
|
|
415
415
|
|
|
416
416
|
def test_client_accepts_only_offered_parents_and_their_children():
|
|
417
|
-
wire = VersionRange()
|
|
417
|
+
wire = VersionRange(VERSION)
|
|
418
418
|
offers = (Offer("default", wire),)
|
|
419
419
|
syn = {
|
|
420
420
|
"version": "2026-09-30",
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
|
|
3
|
+
from statewire import Statewire
|
|
3
4
|
from statewire.protocol import (
|
|
5
|
+
VERSION,
|
|
6
|
+
WIRE_VERSION,
|
|
4
7
|
Adapter,
|
|
5
8
|
NegotiationError,
|
|
6
9
|
Offer,
|
|
@@ -47,13 +50,41 @@ def test_required_optional_and_wildcard():
|
|
|
47
50
|
],
|
|
48
51
|
)
|
|
49
52
|
def test_invalid_negotiation(field, value):
|
|
50
|
-
request = headers(
|
|
53
|
+
request = headers(
|
|
54
|
+
VersionRange(VERSION), (Offer("harness-sdk", VersionRange(VERSION)),)
|
|
55
|
+
)
|
|
51
56
|
request[field] = value
|
|
52
57
|
with pytest.raises(NegotiationError) as error:
|
|
53
|
-
negotiate(request, VersionRange(), (Protocol("harness-sdk"),))
|
|
58
|
+
negotiate(request, VersionRange(VERSION), (Protocol("harness-sdk"),))
|
|
54
59
|
assert error.value.status == 400
|
|
55
60
|
|
|
56
61
|
|
|
62
|
+
def test_a_wire_range_names_its_newest_version():
|
|
63
|
+
with pytest.raises(TypeError):
|
|
64
|
+
VersionRange(min_version="2026-09-13")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_a_host_floor_serves_clients_that_offer_only_the_current_wire():
|
|
68
|
+
class Host(Statewire):
|
|
69
|
+
wire_version = Statewire.VersionRange(WIRE_VERSION, "2026-09-13")
|
|
70
|
+
|
|
71
|
+
current = headers(VersionRange(WIRE_VERSION), None)
|
|
72
|
+
assert negotiate(current, Host.wire_version, (Protocol("default"),)).version == (
|
|
73
|
+
WIRE_VERSION
|
|
74
|
+
)
|
|
75
|
+
older = headers(VersionRange(VERSION), None)
|
|
76
|
+
assert (
|
|
77
|
+
negotiate(older, Host.wire_version, (Protocol("default"),)).version == VERSION
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_a_host_cannot_serve_a_wire_newer_than_the_library():
|
|
82
|
+
with pytest.raises(ValueError, match="wire_version"):
|
|
83
|
+
|
|
84
|
+
class Host(Statewire):
|
|
85
|
+
wire_version = Statewire.VersionRange("2099-01-01", VERSION)
|
|
86
|
+
|
|
87
|
+
|
|
57
88
|
def test_dependency_can_constrain_selected_version():
|
|
58
89
|
broad = VersionRange("2026-09-30", "2026-08-01")
|
|
59
90
|
protocols = (
|
|
@@ -61,7 +92,7 @@ def test_dependency_can_constrain_selected_version():
|
|
|
61
92
|
Protocol("extra", requires={"base": VersionRange("2026-09-01", "2026-08-01")}),
|
|
62
93
|
)
|
|
63
94
|
selected = negotiate(
|
|
64
|
-
headers(broad, (Offer("base", broad), Offer("extra", VersionRange()))),
|
|
95
|
+
headers(broad, (Offer("base", broad), Offer("extra", VersionRange(VERSION)))),
|
|
65
96
|
broad,
|
|
66
97
|
protocols,
|
|
67
98
|
)
|
|
@@ -241,7 +272,7 @@ async def test_http_and_websocket_negotiate_before_prepare_or_initial_commands()
|
|
|
241
272
|
ctx.attach.include("extra", [".", "messages", "m1"])
|
|
242
273
|
return {"count": self.state["count"]}
|
|
243
274
|
|
|
244
|
-
request = headers(VersionRange(), (Offer("missing", VersionRange()),))
|
|
275
|
+
request = headers(VersionRange(VERSION), (Offer("missing", VersionRange(VERSION)),))
|
|
245
276
|
async with statewire_client(Host) as (app, client):
|
|
246
277
|
async with attach_of(
|
|
247
278
|
app,
|
|
@@ -256,7 +287,7 @@ async def test_http_and_websocket_negotiate_before_prepare_or_initial_commands()
|
|
|
256
287
|
assert await socket.next_frame() is None
|
|
257
288
|
assert socket.close_code == 1008
|
|
258
289
|
assert prepared == [] and commands == []
|
|
259
|
-
async with ws_of(app, headers=headers(VersionRange(), None)) as socket:
|
|
290
|
+
async with ws_of(app, headers=headers(VersionRange(VERSION), None)) as socket:
|
|
260
291
|
hello = await socket.next_frame()
|
|
261
292
|
assert hello["syn"]["protocols"] == [
|
|
262
293
|
{"name": "base", "version": "2026-09-30", "seq": 0},
|
|
@@ -383,7 +414,16 @@ async def test_command_context_exposes_the_negotiated_protocol_version():
|
|
|
383
414
|
q2, _, lease2 = await host._register("old", None, selection=older)
|
|
384
415
|
frame = _ingest(
|
|
385
416
|
json.dumps(
|
|
386
|
-
{
|
|
417
|
+
{
|
|
418
|
+
"cmd": [
|
|
419
|
+
{
|
|
420
|
+
"seq": 1,
|
|
421
|
+
"protocol": "counter",
|
|
422
|
+
"method": "increment",
|
|
423
|
+
"params": [],
|
|
424
|
+
}
|
|
425
|
+
]
|
|
426
|
+
}
|
|
387
427
|
)
|
|
388
428
|
)
|
|
389
429
|
await host._admit_frame(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|