statewire 0.23.0__tar.gz → 0.23.2__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.23.0 → statewire-0.23.2}/PKG-INFO +4 -5
- {statewire-0.23.0 → statewire-0.23.2}/README.md +2 -3
- {statewire-0.23.0 → statewire-0.23.2}/examples/demo_app.py +2 -4
- {statewire-0.23.0 → statewire-0.23.2}/pyproject.toml +2 -2
- {statewire-0.23.0 → statewire-0.23.2}/src/statewire/api.py +12 -10
- {statewire-0.23.0 → statewire-0.23.2}/src/statewire/protocol.py +4 -2
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_protocol_negotiation.py +48 -0
- {statewire-0.23.0 → statewire-0.23.2}/.gitignore +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/examples/__init__.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/src/statewire/__init__.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/src/statewire/client.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/src/statewire/document.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/src/statewire/documents.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/src/statewire/filter.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/src/statewire/langgraph.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/src/statewire/limits.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/src/statewire/metrics.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/src/statewire/ops.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/src/statewire/state.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/src/statewire/testing.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/client_helpers.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/statewire_helpers.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/storage_probe.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_attach_fence.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_attach_guardrail.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_attached_hook.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_authorize.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_client.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_client_binding.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_client_ws.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_context.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_date_registry.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_departure.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_document.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_durable_admission.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_eviction.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_filter.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_frames.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_gap_fill.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_idle.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_lanes.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_langgraph.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_lifespan.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_meta.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_observer.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_ops.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_read_filters.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_route_auth.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_start_session.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_state_proxy.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_statewire_hostable.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_storage_bridge.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_stream.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_testing.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_writer_lease.py +0 -0
- {statewire-0.23.0 → statewire-0.23.2}/tests/test_ws.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: statewire
|
|
3
|
-
Version: 0.23.
|
|
3
|
+
Version: 0.23.2
|
|
4
4
|
Summary: Replicate one JSON object over an SSE op stream + a command endpoint
|
|
5
5
|
Project-URL: Repository, https://github.com/assistant-ui/harness-sdk
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Requires-Python: <4.0,>=3.12
|
|
8
8
|
Requires-Dist: fastapi>=0.115
|
|
9
9
|
Requires-Dist: httpx>=0.27
|
|
10
|
-
Requires-Dist: pinned
|
|
10
|
+
Requires-Dist: pinned>=0.17.0
|
|
11
11
|
Requires-Dist: statepatch<0.4,>=0.3.0
|
|
12
12
|
Provides-Extra: langgraph
|
|
13
13
|
Requires-Dist: langchain-core>=0.3; extra == 'langgraph'
|
|
@@ -31,7 +31,7 @@ Extras: `uv add "statewire[langgraph]"`, `uv add "statewire[orjson]"`.
|
|
|
31
31
|
|
|
32
32
|
```python
|
|
33
33
|
from fastapi import FastAPI
|
|
34
|
-
from pinned import
|
|
34
|
+
from pinned import PinnedWorker
|
|
35
35
|
from statewire import Statewire, StatewireReject, command
|
|
36
36
|
|
|
37
37
|
class Counter(Statewire):
|
|
@@ -45,10 +45,9 @@ class Counter(Statewire):
|
|
|
45
45
|
raise StatewireReject("the counter is full (max 10)")
|
|
46
46
|
self.state["count"] += 1
|
|
47
47
|
|
|
48
|
-
worker = PinnedWorker()
|
|
48
|
+
worker = PinnedWorker(hosts={"/threads": Counter})
|
|
49
49
|
app = FastAPI()
|
|
50
50
|
app.include_router(worker)
|
|
51
|
-
app.include_router(PinnedHost(Counter, worker=worker, namespace="/threads"))
|
|
52
51
|
```
|
|
53
52
|
|
|
54
53
|
## Protocols and documents
|
|
@@ -14,7 +14,7 @@ Extras: `uv add "statewire[langgraph]"`, `uv add "statewire[orjson]"`.
|
|
|
14
14
|
|
|
15
15
|
```python
|
|
16
16
|
from fastapi import FastAPI
|
|
17
|
-
from pinned import
|
|
17
|
+
from pinned import PinnedWorker
|
|
18
18
|
from statewire import Statewire, StatewireReject, command
|
|
19
19
|
|
|
20
20
|
class Counter(Statewire):
|
|
@@ -28,10 +28,9 @@ class Counter(Statewire):
|
|
|
28
28
|
raise StatewireReject("the counter is full (max 10)")
|
|
29
29
|
self.state["count"] += 1
|
|
30
30
|
|
|
31
|
-
worker = PinnedWorker()
|
|
31
|
+
worker = PinnedWorker(hosts={"/threads": Counter})
|
|
32
32
|
app = FastAPI()
|
|
33
33
|
app.include_router(worker)
|
|
34
|
-
app.include_router(PinnedHost(Counter, worker=worker, namespace="/threads"))
|
|
35
34
|
```
|
|
36
35
|
|
|
37
36
|
## Protocols and documents
|
|
@@ -15,7 +15,7 @@ window), a hard limit that rejects with a message (StatewireSendError), a
|
|
|
15
15
|
import asyncio
|
|
16
16
|
|
|
17
17
|
from fastapi import FastAPI
|
|
18
|
-
from pinned import
|
|
18
|
+
from pinned import PinnedWorker
|
|
19
19
|
from statewire import StatewireReject, Statewire, append, command
|
|
20
20
|
|
|
21
21
|
MAX_COUNT = 10
|
|
@@ -61,8 +61,6 @@ class Counter(Statewire):
|
|
|
61
61
|
await asyncio.sleep(0.03)
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
worker = PinnedWorker()
|
|
65
|
-
router = PinnedHost(Counter, worker=worker, namespace="/threads")
|
|
64
|
+
worker = PinnedWorker(hosts={"/threads": Counter})
|
|
66
65
|
app = FastAPI()
|
|
67
66
|
app.include_router(worker)
|
|
68
|
-
app.include_router(router)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "statewire"
|
|
3
|
-
version = "0.23.
|
|
3
|
+
version = "0.23.2"
|
|
4
4
|
description = "Replicate one JSON object over an SSE op stream + a command endpoint"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
7
7
|
requires-python = ">=3.12,<4.0"
|
|
8
8
|
dependencies = [
|
|
9
|
-
"pinned>=0.
|
|
9
|
+
"pinned>=0.17.0",
|
|
10
10
|
"statepatch>=0.3.0,<0.4",
|
|
11
11
|
"fastapi>=0.115",
|
|
12
12
|
"httpx>=0.27",
|
|
@@ -1954,9 +1954,10 @@ class Statewire(PinnedAPI):
|
|
|
1954
1954
|
|
|
1955
1955
|
def _native(self, selection: Selection) -> bool:
|
|
1956
1956
|
return not any(
|
|
1957
|
-
|
|
1957
|
+
a.state_down is not None or a.documents_down is not None
|
|
1958
1958
|
for p in self.protocols
|
|
1959
1959
|
if p.name in selection.protocols
|
|
1960
|
+
for a in p.path(selection.protocols[p.name])
|
|
1960
1961
|
)
|
|
1961
1962
|
|
|
1962
1963
|
def _project(
|
|
@@ -1971,15 +1972,16 @@ class Statewire(PinnedAPI):
|
|
|
1971
1972
|
continue
|
|
1972
1973
|
current = {i: d for i, d in result.items() if d.protocol == protocol.name}
|
|
1973
1974
|
for adapter in reversed(path):
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1975
|
+
if adapter.state_down is not None:
|
|
1976
|
+
current = {
|
|
1977
|
+
i: replace(
|
|
1978
|
+
d,
|
|
1979
|
+
value=adapter.state_down(deepcopy(d.value))
|
|
1980
|
+
if d.main
|
|
1981
|
+
else deepcopy(d.value),
|
|
1982
|
+
)
|
|
1983
|
+
for i, d in current.items()
|
|
1984
|
+
}
|
|
1983
1985
|
if adapter.documents_down is not None:
|
|
1984
1986
|
current = adapter.documents_down(deepcopy(current))
|
|
1985
1987
|
if any(d.protocol != protocol.name for d in current.values()):
|
|
@@ -151,7 +151,7 @@ def _identity(value: Any) -> Any:
|
|
|
151
151
|
class Adapter:
|
|
152
152
|
older: str
|
|
153
153
|
newer: str
|
|
154
|
-
state_down: Callable[[Any], Any]
|
|
154
|
+
state_down: Callable[[Any], Any] | None = None # None: the state shape is unchanged
|
|
155
155
|
command_up: Callable[[dict[str, Any]], dict[str, Any]] = _identity
|
|
156
156
|
result_down: Callable[[Any], Any] = _identity
|
|
157
157
|
error_down: Callable[[Any], Any] = _identity
|
|
@@ -219,7 +219,9 @@ class Protocol:
|
|
|
219
219
|
if kind.endswith("_down"):
|
|
220
220
|
path = tuple(reversed(path))
|
|
221
221
|
for adapter in path:
|
|
222
|
-
|
|
222
|
+
step = getattr(adapter, kind)
|
|
223
|
+
if step is not None:
|
|
224
|
+
value = step(deepcopy(value))
|
|
223
225
|
return value
|
|
224
226
|
|
|
225
227
|
|
|
@@ -387,6 +387,44 @@ async def test_native_updates_do_not_snapshot_the_primary_document(monkeypatch):
|
|
|
387
387
|
host._remove_subscriber(q)
|
|
388
388
|
|
|
389
389
|
|
|
390
|
+
async def test_a_command_only_adapter_keeps_older_attaches_native(monkeypatch):
|
|
391
|
+
import json
|
|
392
|
+
from statewire import Statewire
|
|
393
|
+
from statewire_helpers import make_instance
|
|
394
|
+
|
|
395
|
+
class Host(Statewire):
|
|
396
|
+
protocols = (
|
|
397
|
+
Protocol(
|
|
398
|
+
"base",
|
|
399
|
+
"2026-09-07",
|
|
400
|
+
"2026-08-01",
|
|
401
|
+
(Adapter("2026-08-01", "2026-09-01", command_up=lambda c: c),),
|
|
402
|
+
),
|
|
403
|
+
)
|
|
404
|
+
|
|
405
|
+
host = make_instance(Host)
|
|
406
|
+
host.state = {"count": 0, "messages": ["large transcript"] * 1000}
|
|
407
|
+
older, _, _ = await host._register(
|
|
408
|
+
"older", None, selection=Selection("2026-09-07", {"base": "2026-08-01"})
|
|
409
|
+
)
|
|
410
|
+
source = host._shared_documents
|
|
411
|
+
snapshots = []
|
|
412
|
+
|
|
413
|
+
def read(*, include_primary=True):
|
|
414
|
+
snapshots.append(include_primary)
|
|
415
|
+
return source(include_primary=include_primary)
|
|
416
|
+
|
|
417
|
+
monkeypatch.setattr(host, "_shared_documents", read)
|
|
418
|
+
host.state["count"] = 1
|
|
419
|
+
host.flush()
|
|
420
|
+
packets, _ = older.get_nowait()
|
|
421
|
+
assert json.loads(packets[0])["ops"] == [
|
|
422
|
+
{"op": "replace", "path": ["count"], "value": 1}
|
|
423
|
+
]
|
|
424
|
+
assert snapshots == [False]
|
|
425
|
+
host._remove_subscriber(older)
|
|
426
|
+
|
|
427
|
+
|
|
390
428
|
async def test_command_context_exposes_the_negotiated_protocol_version():
|
|
391
429
|
import json
|
|
392
430
|
import time
|
|
@@ -438,3 +476,13 @@ async def test_command_context_exposes_the_negotiated_protocol_version():
|
|
|
438
476
|
|
|
439
477
|
ctx, _effects = await command_context(host, client_id="direct")
|
|
440
478
|
assert ctx.version == "2026-09-07"
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
def test_convert_skips_an_adapter_without_the_step():
|
|
482
|
+
protocol = Protocol(
|
|
483
|
+
"base",
|
|
484
|
+
"2026-09-07",
|
|
485
|
+
"2026-08-01",
|
|
486
|
+
(Adapter("2026-08-01", "2026-09-07", command_up=lambda c: c),),
|
|
487
|
+
)
|
|
488
|
+
assert protocol.convert("2026-08-01", "state_down", {"a": 1}) == {"a": 1}
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|