statewire 0.23.3__tar.gz → 0.23.5__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.
Files changed (56) hide show
  1. {statewire-0.23.3 → statewire-0.23.5}/PKG-INFO +1 -1
  2. {statewire-0.23.3 → statewire-0.23.5}/pyproject.toml +1 -1
  3. {statewire-0.23.3 → statewire-0.23.5}/src/statewire/api.py +106 -21
  4. {statewire-0.23.3 → statewire-0.23.5}/src/statewire/protocol.py +1 -1
  5. {statewire-0.23.3 → statewire-0.23.5}/tests/test_durable_admission.py +58 -0
  6. {statewire-0.23.3 → statewire-0.23.5}/tests/test_gap_fill.py +34 -28
  7. {statewire-0.23.3 → statewire-0.23.5}/.gitignore +0 -0
  8. {statewire-0.23.3 → statewire-0.23.5}/README.md +0 -0
  9. {statewire-0.23.3 → statewire-0.23.5}/examples/__init__.py +0 -0
  10. {statewire-0.23.3 → statewire-0.23.5}/examples/demo_app.py +0 -0
  11. {statewire-0.23.3 → statewire-0.23.5}/src/statewire/__init__.py +0 -0
  12. {statewire-0.23.3 → statewire-0.23.5}/src/statewire/client.py +0 -0
  13. {statewire-0.23.3 → statewire-0.23.5}/src/statewire/document.py +0 -0
  14. {statewire-0.23.3 → statewire-0.23.5}/src/statewire/documents.py +0 -0
  15. {statewire-0.23.3 → statewire-0.23.5}/src/statewire/filter.py +0 -0
  16. {statewire-0.23.3 → statewire-0.23.5}/src/statewire/langgraph.py +0 -0
  17. {statewire-0.23.3 → statewire-0.23.5}/src/statewire/limits.py +0 -0
  18. {statewire-0.23.3 → statewire-0.23.5}/src/statewire/metrics.py +0 -0
  19. {statewire-0.23.3 → statewire-0.23.5}/src/statewire/ops.py +0 -0
  20. {statewire-0.23.3 → statewire-0.23.5}/src/statewire/state.py +0 -0
  21. {statewire-0.23.3 → statewire-0.23.5}/src/statewire/testing.py +0 -0
  22. {statewire-0.23.3 → statewire-0.23.5}/tests/client_helpers.py +0 -0
  23. {statewire-0.23.3 → statewire-0.23.5}/tests/statewire_helpers.py +0 -0
  24. {statewire-0.23.3 → statewire-0.23.5}/tests/storage_probe.py +0 -0
  25. {statewire-0.23.3 → statewire-0.23.5}/tests/test_attach_fence.py +0 -0
  26. {statewire-0.23.3 → statewire-0.23.5}/tests/test_attach_guardrail.py +0 -0
  27. {statewire-0.23.3 → statewire-0.23.5}/tests/test_attached_hook.py +0 -0
  28. {statewire-0.23.3 → statewire-0.23.5}/tests/test_authorize.py +0 -0
  29. {statewire-0.23.3 → statewire-0.23.5}/tests/test_client.py +0 -0
  30. {statewire-0.23.3 → statewire-0.23.5}/tests/test_client_binding.py +0 -0
  31. {statewire-0.23.3 → statewire-0.23.5}/tests/test_client_ws.py +0 -0
  32. {statewire-0.23.3 → statewire-0.23.5}/tests/test_context.py +0 -0
  33. {statewire-0.23.3 → statewire-0.23.5}/tests/test_date_registry.py +0 -0
  34. {statewire-0.23.3 → statewire-0.23.5}/tests/test_departure.py +0 -0
  35. {statewire-0.23.3 → statewire-0.23.5}/tests/test_document.py +0 -0
  36. {statewire-0.23.3 → statewire-0.23.5}/tests/test_eviction.py +0 -0
  37. {statewire-0.23.3 → statewire-0.23.5}/tests/test_filter.py +0 -0
  38. {statewire-0.23.3 → statewire-0.23.5}/tests/test_frames.py +0 -0
  39. {statewire-0.23.3 → statewire-0.23.5}/tests/test_idle.py +0 -0
  40. {statewire-0.23.3 → statewire-0.23.5}/tests/test_lanes.py +0 -0
  41. {statewire-0.23.3 → statewire-0.23.5}/tests/test_langgraph.py +0 -0
  42. {statewire-0.23.3 → statewire-0.23.5}/tests/test_lifespan.py +0 -0
  43. {statewire-0.23.3 → statewire-0.23.5}/tests/test_meta.py +0 -0
  44. {statewire-0.23.3 → statewire-0.23.5}/tests/test_observer.py +0 -0
  45. {statewire-0.23.3 → statewire-0.23.5}/tests/test_ops.py +0 -0
  46. {statewire-0.23.3 → statewire-0.23.5}/tests/test_protocol_negotiation.py +0 -0
  47. {statewire-0.23.3 → statewire-0.23.5}/tests/test_read_filters.py +0 -0
  48. {statewire-0.23.3 → statewire-0.23.5}/tests/test_route_auth.py +0 -0
  49. {statewire-0.23.3 → statewire-0.23.5}/tests/test_start_session.py +0 -0
  50. {statewire-0.23.3 → statewire-0.23.5}/tests/test_state_proxy.py +0 -0
  51. {statewire-0.23.3 → statewire-0.23.5}/tests/test_statewire_hostable.py +0 -0
  52. {statewire-0.23.3 → statewire-0.23.5}/tests/test_storage_bridge.py +0 -0
  53. {statewire-0.23.3 → statewire-0.23.5}/tests/test_stream.py +0 -0
  54. {statewire-0.23.3 → statewire-0.23.5}/tests/test_testing.py +0 -0
  55. {statewire-0.23.3 → statewire-0.23.5}/tests/test_writer_lease.py +0 -0
  56. {statewire-0.23.3 → statewire-0.23.5}/tests/test_ws.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: statewire
3
- Version: 0.23.3
3
+ Version: 0.23.5
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "statewire"
3
- version = "0.23.3"
3
+ version = "0.23.5"
4
4
  description = "Replicate one JSON object over an SSE op stream + a command endpoint"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -18,9 +18,11 @@ statement re-emits its stored verdict — ``applied`` while still in flight
18
18
  once the first applied entry was emitted, nothing before that (the answers
19
19
  ride the stream when ready), ``expired`` once the outcome outlived
20
20
  retention) and a gap refuses the frame whole via ``{syn}`` carrying every
21
- lane's watermark, nothing consumed. Under wire ``2026-11-01`` a re-sent seq
22
- is a protocol violation instead, and the attach frame's ``res`` cursor
23
- answers the same way, per durable lane, every seq above it on the hello. Durable lanes belong to the client id
21
+ lane's watermark, nothing consumed. Every wire absorbs a re-sent seq this
22
+ way: another attach of the client id may have landed it first (a gone tab's
23
+ late frame, a sharer's resend). Under wire ``2026-11-01`` the attach frame's
24
+ ``res`` cursor answers the same way, per durable lane, every seq above it on
25
+ the hello. Durable lanes belong to the client id
24
26
  and continue across attaches; ephemeral lanes (subprotocols registered with
25
27
  ``record="ephemeral"``) belong to the attach, restart at 1, and answer on
26
28
  that attach only. Ephemeral statements in the attach frame are admitted
@@ -220,12 +222,14 @@ ATTACHER_HEADER = ops.ATTACHER_HEADER
220
222
  RESULT_CACHE_TTL = 30.0
221
223
  TRAY_RETIRING_RETRY_MS = 1000
222
224
  RESULT_CACHE_LIMIT = 256
225
+ _PARKED_ANSWERS = 64
223
226
  MAX_DRAIN_DEPTH = 50
224
227
  MAX_JSON_DEPTH = 256
225
228
  Handler = Callable[..., Awaitable[Any]]
226
229
 
227
230
  _UNSET: Any = object()
228
231
  _UNBOUND: Any = object()
232
+ _ABSENT: Any = object()
229
233
  _WS_FIN_ATTEMPTED = "statewire.ws_fin_attempted"
230
234
 
231
235
 
@@ -664,7 +668,10 @@ class _Group:
664
668
  class ClientCommands(Tray):
665
669
  """Per-client durable lanes: seq maps each protocol to its admitted-seq
666
670
  watermark, the pool holds admitted frames (each one frame's durable
667
- statements) until they execute. Admission enlists kick (the running
671
+ statements) until they execute. parked holds ``{protocol, seq, response}``
672
+ of commands answered through ``_settle_parked``: None until the answer
673
+ lands, then kept for the latest ``_PARKED_ANSWERS`` so a redelivered frame
674
+ or a gap-fill reads it. Admission enlists kick (the running
668
675
  claim) before the pool append before seq, so no crash point strands or
669
676
  loses a pooled frame; the ack heals seq over the popped frame, so a
670
677
  crash-cut seq never durably understates an executed frame.
@@ -677,6 +684,7 @@ class ClientCommands(Tray):
677
684
  drain_on_eviction = True
678
685
  seq = persistent({})
679
686
  pool = persistent([])
687
+ parked = persistent([])
680
688
  quarantine = persistent([])
681
689
  identity = persistent(None)
682
690
  identity_through = persistent({})
@@ -814,6 +822,39 @@ class ClientCommands(Tray):
814
822
  self._check_above(statements)
815
823
  self._advance(statements)
816
824
 
825
+ def parked_answer(self, protocol: str, seq: int) -> Any:
826
+ """A parked command's stored answer: None while pending, _ABSENT when not parked."""
827
+ return next(
828
+ (
829
+ p["response"]
830
+ for p in self.parked.value
831
+ if p["protocol"] == protocol and p["seq"] == seq
832
+ ),
833
+ _ABSENT,
834
+ )
835
+
836
+ def pooled(self, protocol: str, seq: int) -> bool:
837
+ return any(
838
+ s["protocol"] == protocol and s["seq"] == seq
839
+ for frame in self.pool.value
840
+ for s in _pool_statements(frame)
841
+ )
842
+
843
+ @inbox
844
+ def answer(self, protocol: str, seq: int, response: dict[str, Any]) -> None:
845
+ """Store a parked or pooled command's answer."""
846
+ kept = [
847
+ p
848
+ for p in self.parked.value
849
+ if not (p["protocol"] == protocol and p["seq"] == seq)
850
+ ]
851
+ answered = [p for p in kept if p["response"] is not None]
852
+ stale = answered[: max(0, len(answered) + 1 - _PARKED_ANSWERS)]
853
+ self.parked.value = [
854
+ *(p for p in kept if not any(p is q for q in stale)),
855
+ {"protocol": protocol, "seq": seq, "response": response},
856
+ ]
857
+
817
858
  @inbox
818
859
  def discard(self, frames: list[tuple[str, list[dict[str, Any]]]]) -> None:
819
860
  """Remove held frames; their seqs stay consumed."""
@@ -908,12 +949,11 @@ class _Lane:
908
949
  "type": "rejected",
909
950
  **_IDENTITY_UNAVAILABLE,
910
951
  }
911
- if tray is not None and any(
912
- entry["protocol"] == self.protocol and entry["seq"] == seq
913
- for frame in tray.pool.value
914
- for entry in _pool_statements(frame)
915
- ):
916
- return None # pooled, not yet executed: answers ride the stream
952
+ answer = _ABSENT if tray is None else tray.parked_answer(self.protocol, seq)
953
+ if answer is not None and answer is not _ABSENT:
954
+ return {"protocol": self.protocol, "seq": seq, **answer}
955
+ if answer is None or (tray is not None and tray.pooled(self.protocol, seq)):
956
+ return None # pooled or parked: answers ride the stream
917
957
  return {"protocol": self.protocol, "seq": seq, "type": "result-unavailable"}
918
958
 
919
959
  def _retain(self, response: dict[str, Any]) -> None:
@@ -1240,7 +1280,8 @@ def _release_admission(applied: Callable[[], None]) -> None:
1240
1280
  the caller bounds its parked commands. ``applied`` is the command's
1241
1281
  ``ctx.applied``; any other callable is ignored. On a durable host the
1242
1282
  caller must have durably recorded the command's intent first: a crash
1243
- after the release no longer redelivers the frame. No-op after applied or
1283
+ after the release no longer redelivers the frame, and the seq stays
1284
+ pending until ``_settle_parked`` answers it. No-op after applied or
1244
1285
  settle."""
1245
1286
  ctx = getattr(applied, "__self__", None)
1246
1287
  if not isinstance(ctx, StatewireCommandContext):
@@ -1249,6 +1290,12 @@ def _release_admission(applied: Callable[[], None]) -> None:
1249
1290
  if inv.applied or inv.settled:
1250
1291
  return
1251
1292
  inv.parked = True
1293
+ if inv.tray_ctx is not None:
1294
+ commands = inv.tray_ctx.tray
1295
+ commands.parked.value = [
1296
+ *commands.parked.value,
1297
+ {"protocol": inv.lane.protocol, "seq": inv.seq, "response": None},
1298
+ ]
1252
1299
  inv.finish()
1253
1300
 
1254
1301
 
@@ -1263,6 +1310,48 @@ def _admission_key(applied: Callable[[], None]) -> str | None:
1263
1310
  return json.dumps([inv.client.id, inv.lane.protocol, inv.seq])
1264
1311
 
1265
1312
 
1313
+ async def _settle_parked(host: "Statewire", key: str, response: dict[str, Any]) -> None:
1314
+ """Internal (harness_sdk's run manager): answer a durable command by its
1315
+ ``_admission_key`` and store the answer in its client's ClientCommands
1316
+ row; returns once that write is durable. ``response`` is a
1317
+ ``_response_of`` verdict; a command already answered stays as it was."""
1318
+ client_id, protocol, seq = json.loads(key)
1319
+ while True:
1320
+ try:
1321
+ tray = await host.client_commands.get(client_id)
1322
+ except KeyError:
1323
+ return
1324
+ if tray._retirement is None:
1325
+ break
1326
+ await tray._retirement.task
1327
+ stored = tray.parked_answer(protocol, seq)
1328
+ if stored is not _ABSENT and stored is not None:
1329
+ return
1330
+ if stored is _ABSENT and not tray.pooled(protocol, seq):
1331
+ return
1332
+ lane = host._pooled_client(tray).lane(protocol)
1333
+ inv = lane.inflight.get(seq)
1334
+ if inv is not None:
1335
+ host._settle(inv, response)
1336
+ else:
1337
+ lane.settle_late(seq, response)
1338
+ await tray.answer(protocol, seq, response)
1339
+
1340
+
1341
+ def _response_of(outcome: Any) -> dict[str, Any]:
1342
+ """Internal: a handler's return value, or the exception it raised, as its verdict."""
1343
+ if isinstance(outcome, StatewireReject):
1344
+ response: dict[str, Any] = {"type": "rejected", "message": outcome.message}
1345
+ if outcome.code is not None:
1346
+ response["code"] = outcome.code
1347
+ if outcome.payload is not None:
1348
+ response.update(_payload_fields(outcome.payload))
1349
+ return response
1350
+ if isinstance(outcome, BaseException):
1351
+ return {"type": "failed", "message": "the command failed"}
1352
+ return {"type": "accepted", **({} if outcome is None else _payload_fields(outcome))}
1353
+
1354
+
1266
1355
  class StatewireReject(Exception):
1267
1356
  """Definitive handler rejection: a ``rejected`` verdict rides ``cmd`` on
1268
1357
  the stream, the seq is consumed (no re-run on retry), and message/payload
@@ -3228,8 +3317,6 @@ class Statewire(PinnedAPI):
3228
3317
  for name in _by_protocol(frame.cmd)
3229
3318
  }
3230
3319
  new = [s for s in frame.cmd if s["seq"] > through[s["protocol"]]]
3231
- if len(new) < len(frame.cmd) and selection.version >= GAP_FILL_VERSION:
3232
- raise _Violation("re-sent seq at or below the watermark")
3233
3320
  for statement in frame.cmd:
3234
3321
  if statement["seq"] <= through[statement["protocol"]]:
3235
3322
  # a re-asked seq gets its stored verdict re-emitted on the stream
@@ -3458,7 +3545,10 @@ class Statewire(PinnedAPI):
3458
3545
  }
3459
3546
  slots = []
3460
3547
  for statement in statements:
3461
- if denied is not None:
3548
+ answer = commands_tray.parked_answer(statement["protocol"], statement["seq"])
3549
+ if answer is not None and answer is not _ABSENT:
3550
+ slot = answer
3551
+ elif denied is not None:
3462
3552
  slot = dict(denied)
3463
3553
  else:
3464
3554
  prepared, rejection = self._prepare_member(statement)
@@ -3602,7 +3692,7 @@ class Statewire(PinnedAPI):
3602
3692
  seq = statement["seq"]
3603
3693
  lane = self._lane(client, lease, statement["protocol"])
3604
3694
  if isinstance(slot, dict):
3605
- # Static rejection consumes its seq with a rejected verdict.
3695
+ # A static rejection, or a stored answer, consumes its seq.
3606
3696
  lane.settle(seq, {"type": "rejected", **slot})
3607
3697
  continue
3608
3698
  prepared = slot
@@ -3680,12 +3770,7 @@ class Statewire(PinnedAPI):
3680
3770
  try:
3681
3771
  value = await prepared.handler(*prepared.params, **kwargs)
3682
3772
  except StatewireReject as exc:
3683
- response: dict[str, Any] = {"type": "rejected", "message": exc.message}
3684
- if exc.code is not None:
3685
- response["code"] = exc.code
3686
- if exc.payload is not None:
3687
- response.update(_payload_fields(exc.payload))
3688
- self._settle(inv, response)
3773
+ self._settle(inv, _response_of(exc))
3689
3774
  except HTTPException as exc:
3690
3775
  detail = (
3691
3776
  exc.detail if isinstance(exc.detail, str) else f"HTTP {exc.status_code}"
@@ -6,7 +6,7 @@ from typing import Any, Callable, Mapping
6
6
 
7
7
  VERSION = "2026-09-30"
8
8
  WIRE_VERSION = "2026-11-02"
9
- # attach carries a results cursor; a re-sent seq at or below the watermark is a violation
9
+ # attach carries a results cursor; the hello answers every seq above it
10
10
  GAP_FILL_VERSION = "2026-11-01"
11
11
  # an attach names its attacher; a new attach retires the same attacher's earlier ones first
12
12
  FENCE_VERSION = "2026-11-02"
@@ -1182,3 +1182,61 @@ async def test_a_released_admission_frees_the_pool_slot_before_the_handler_settl
1182
1182
  assert seen == [False]
1183
1183
  assert keys == [('["old-client", "default", 1]', None)]
1184
1184
  release.set()
1185
+
1186
+
1187
+ async def test_a_parked_seq_stays_pending_across_a_restart_until_settled():
1188
+ """``_settle_parked`` (the run manager's seam): a parked command a restart
1189
+ left without an invocation reads pending, then its stored answer, once."""
1190
+ from statewire.api import _response_of, _settle_parked
1191
+
1192
+ store = MemoryStateStore()
1193
+ row = ("/test", "test", "client_commands", "c1")
1194
+ parked = {"protocol": "default", "seq": 3, "response": None}
1195
+ store.trays[row] = (False, {"seq": {"default": 3}, "parked": [parked]})
1196
+ key = '["c1", "default", 3]'
1197
+ answer = {"protocol": "default", "seq": 3, "type": "accepted", "payload": {"echo": 1}}
1198
+ async with instance(Admitting, state_store=store) as host:
1199
+ commands = await host.client_commands.get("c1")
1200
+ lane = host._pooled_client(commands).lane("default")
1201
+ assert lane.duplicate_answer(2)["type"] == "result-unavailable"
1202
+ assert lane.duplicate_answer(3) is None
1203
+ await _settle_parked(host, key, _response_of({"echo": 1}))
1204
+ await _settle_parked(host, key, _response_of(None))
1205
+ assert lane.duplicate_answer(3) == answer
1206
+ lane.results.clear()
1207
+ assert lane.duplicate_answer(3) == answer
1208
+ await host.frontier.wait()
1209
+ assert store.trays[row][1]["parked"] == [
1210
+ {**parked, "response": {"type": "accepted", "payload": {"echo": 1}}}
1211
+ ]
1212
+
1213
+
1214
+ async def test_a_pooled_statement_with_a_stored_answer_answers_without_running():
1215
+ from statewire.protocol import VERSION
1216
+
1217
+ calls = []
1218
+
1219
+ class Restored(Admitting):
1220
+ @command
1221
+ async def ask(self, by: int):
1222
+ calls.append(by)
1223
+ return {"echo": by}
1224
+
1225
+ store = MemoryStateStore()
1226
+ row = ("/test", "test", "client_commands", "c1")
1227
+ frame = [{**statement(seq, params=[seq]), "_statewire_version": VERSION} for seq in (1, 2)]
1228
+ stored = {"type": "rejected", "message": "no", "code": "nope"}
1229
+ store.trays[row] = (True, {
1230
+ "seq": {"default": 2},
1231
+ "pool": [{"statewire_admission": 1, "auth": {"value": None}, "statements": frame}],
1232
+ "parked": [{"protocol": "default", "seq": 1, "response": stored}],
1233
+ })
1234
+ async with instance(Restored, state_store=store) as host:
1235
+ async with asyncio.timeout(2):
1236
+ while pooled_statements(store):
1237
+ await host.frontier.wait()
1238
+ await asyncio.sleep(0.01)
1239
+ results = host._clients["c1"].lane("default").results
1240
+ assert results[1][1] == {"protocol": "default", "seq": 1, **stored}
1241
+ assert results[2][1]["type"] == "accepted"
1242
+ assert calls == [2]
@@ -1,6 +1,6 @@
1
1
  """Contract: the 2026-11-01 attach results cursor (`res`) gap-fills the hello
2
- `cmd`; a re-sent seq at or below the watermark is a protocol violation.
3
- Attaches selecting 2026-09-30 keep re-send re-emits."""
2
+ `cmd`. A re-sent seq at or below the watermark re-emits its verdict on every
3
+ wire, as 2026-09-30 always did."""
4
4
 
5
5
  import asyncio
6
6
 
@@ -126,34 +126,40 @@ async def test_a_cursor_at_the_watermark_fills_nothing():
126
126
  assert "cmd" not in await stream.next_event()
127
127
 
128
128
 
129
- async def test_a_resent_seq_is_a_violation_under_the_gap_fill_contract():
129
+ async def test_a_resent_seq_reemits_under_the_gap_fill_contract():
130
+ """Another attach of the client id may land a seq first (a gone tab's
131
+ late frame): the copy re-emits its verdict and never runs again."""
130
132
  async with statewire_client(make_host()) as (app, client):
131
- async with attach_of(app, {"headers": {}}, headers=GAP_FILL) as stream:
133
+ async with attach_of(app, {"headers": {}}, headers=GAP_FILL) as gone:
134
+ await gone.next_event()
135
+ gone_lease = gone.headers["statewire-lease"]
136
+ async with attach_of(app, {"headers": {}}, headers=GAP_FILL) as stream:
137
+ hello = await stream.next_event()
138
+ assert hello["syn"]["protocols"][0]["seq"] == 0
139
+ lease = stream.headers["statewire-lease"]
140
+ late = await post_frame(
141
+ client, {"cmd": [statement(1)]}, lease=gone_lease
142
+ )
143
+ assert late.status_code == 200
144
+ await cmds_until(stream, answer(1, "result", payload=1))
145
+ frame = {"cmd": [statement(1), statement(2)]}
146
+ response = await post_frame(client, frame, lease=lease)
147
+ assert response.status_code == 200
148
+ assert response.json() == {}
149
+ # the re-emit, then seq 2 ran second: count 2, not 3
150
+ await cmds_until(
151
+ stream,
152
+ answer(1, "result", payload=1),
153
+ answer(2, "result", payload=2),
154
+ )
155
+ async with attach_of(app, {"cmd": [statement(2)]}, headers=GAP_FILL) as stream:
156
+ hello = await stream.next_event()
157
+ assert "fin" not in hello
158
+ assert hello["syn"]["protocols"][0]["seq"] == 2
159
+ await cmds_until(stream, answer(2, "result", payload=2))
160
+ async with attach_of(app, {"cmd": [statement(3)]}, headers=GAP_FILL) as stream:
132
161
  await stream.next_event()
133
- frame = {"cmd": [statement(1)]}
134
- assert (await post_frame(client, frame)).status_code == 200
135
- await cmds_until(stream, answer(1, "result", payload=1))
136
- response = await post_frame(client, {"cmd": [statement(1), statement(2)]})
137
- assert response.status_code == 400
138
- assert response.json() == {"error": "re-sent seq at or below the watermark"}
139
- assert await stream.next_event() == {
140
- "fin": {
141
- "reason": "protocol-error",
142
- "message": "re-sent seq at or below the watermark",
143
- }
144
- }
145
- response = await client.post(
146
- "/threads/t1/stream",
147
- json={"cmd": [statement(1)]},
148
- headers={api.CLIENT_ID_HEADER: "c1", **GAP_FILL},
149
- )
150
- assert response.status_code == 400
151
- assert response.json() == {
152
- "fin": {
153
- "reason": "protocol-error",
154
- "message": "re-sent seq at or below the watermark",
155
- }
156
- }
162
+ await cmds_until(stream, answer(3, "result", payload=3))
157
163
 
158
164
 
159
165
  async def test_a_resent_seq_reemits_under_the_2026_09_30_contract():
File without changes
File without changes
File without changes
File without changes