wirestead 0.9.2__tar.gz → 0.9.4__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 (49) hide show
  1. {wirestead-0.9.2 → wirestead-0.9.4}/.github/workflows/release.yml +1 -1
  2. {wirestead-0.9.2 → wirestead-0.9.4}/.gitignore +13 -3
  3. {wirestead-0.9.2 → wirestead-0.9.4}/CHANGELOG.md +37 -0
  4. {wirestead-0.9.2 → wirestead-0.9.4}/PKG-INFO +1 -1
  5. wirestead-0.9.4/VCPKG_BASELINE +1 -0
  6. wirestead-0.9.4/WIRESTEAD_CORE_REF +1 -0
  7. {wirestead-0.9.2 → wirestead-0.9.4}/bindings/python/module.cpp.in +110 -0
  8. wirestead-0.9.4/docs/api.md +56 -0
  9. {wirestead-0.9.2 → wirestead-0.9.4}/docs/compatibility.md +2 -0
  10. {wirestead-0.9.2 → wirestead-0.9.4}/pyproject.toml +1 -1
  11. wirestead-0.9.4/src/wirestead/_version.py +1 -0
  12. {wirestead-0.9.2 → wirestead-0.9.4}/tests/test_api_surface.py +74 -0
  13. wirestead-0.9.4/tests/test_project_metadata.py +63 -0
  14. {wirestead-0.9.2 → wirestead-0.9.4}/tests/test_tcp_loopback.py +44 -0
  15. {wirestead-0.9.2 → wirestead-0.9.4}/vcpkg.json +1 -1
  16. wirestead-0.9.2/VCPKG_BASELINE +0 -1
  17. wirestead-0.9.2/WIRESTEAD_CORE_REF +0 -1
  18. wirestead-0.9.2/docs/api.md +0 -13
  19. wirestead-0.9.2/src/wirestead/_version.py +0 -1
  20. wirestead-0.9.2/tests/test_project_metadata.py +0 -35
  21. {wirestead-0.9.2 → wirestead-0.9.4}/.clang-format +0 -0
  22. {wirestead-0.9.2 → wirestead-0.9.4}/.cmake-format.py +0 -0
  23. {wirestead-0.9.2 → wirestead-0.9.4}/.github/dependabot.yml +0 -0
  24. {wirestead-0.9.2 → wirestead-0.9.4}/.github/pull_request_template.md +0 -0
  25. {wirestead-0.9.2 → wirestead-0.9.4}/.github/workflows/ci.yml +0 -0
  26. {wirestead-0.9.2 → wirestead-0.9.4}/.github/workflows/code-formatting.yml +0 -0
  27. {wirestead-0.9.2 → wirestead-0.9.4}/.github/workflows/vcpkg-baseline-sync.yml +0 -0
  28. {wirestead-0.9.2 → wirestead-0.9.4}/CMakeLists.txt +0 -0
  29. {wirestead-0.9.2 → wirestead-0.9.4}/CONTRIBUTING.md +0 -0
  30. {wirestead-0.9.2 → wirestead-0.9.4}/LICENSE +0 -0
  31. {wirestead-0.9.2 → wirestead-0.9.4}/NOTICE +0 -0
  32. {wirestead-0.9.2 → wirestead-0.9.4}/README.md +0 -0
  33. {wirestead-0.9.2 → wirestead-0.9.4}/bindings/python/diagnose_windows_import.py +0 -0
  34. {wirestead-0.9.2 → wirestead-0.9.4}/cmake/FindOrBuildWiresteadCore.cmake +0 -0
  35. {wirestead-0.9.2 → wirestead-0.9.4}/docs/installation.md +0 -0
  36. {wirestead-0.9.2 → wirestead-0.9.4}/docs/packaging.md +0 -0
  37. {wirestead-0.9.2 → wirestead-0.9.4}/docs/packet-probe-viewer-ipc.md +0 -0
  38. {wirestead-0.9.2 → wirestead-0.9.4}/docs/release.md +0 -0
  39. {wirestead-0.9.2 → wirestead-0.9.4}/scripts/consumer_smoke.py +0 -0
  40. {wirestead-0.9.2 → wirestead-0.9.4}/scripts/run_wheel_consumer_smoke.py +0 -0
  41. {wirestead-0.9.2 → wirestead-0.9.4}/scripts/verify.sh +0 -0
  42. {wirestead-0.9.2 → wirestead-0.9.4}/src/wirestead/__init__.py +0 -0
  43. {wirestead-0.9.2 → wirestead-0.9.4}/src/wirestead/asyncio.py +0 -0
  44. {wirestead-0.9.2 → wirestead-0.9.4}/src/wirestead/py.typed +0 -0
  45. {wirestead-0.9.2 → wirestead-0.9.4}/tests/conftest.py +0 -0
  46. {wirestead-0.9.2 → wirestead-0.9.4}/tests/test_asyncio_uds.py +0 -0
  47. {wirestead-0.9.2 → wirestead-0.9.4}/tests/test_import.py +0 -0
  48. {wirestead-0.9.2 → wirestead-0.9.4}/tests/test_udp_loopback.py +0 -0
  49. {wirestead-0.9.2 → wirestead-0.9.4}/tests/test_uds_loopback.py +0 -0
@@ -277,7 +277,7 @@ jobs:
277
277
  echo "CIBW_BEFORE_ALL_LINUX=dnf install -y ninja-build zip unzip perl-IPC-Cmd && git init /vcpkg && git -C /vcpkg remote add origin https://github.com/microsoft/vcpkg.git && git -C /vcpkg fetch --depth 1 origin ${sha} && git -C /vcpkg checkout FETCH_HEAD && /vcpkg/bootstrap-vcpkg.sh && /vcpkg/vcpkg install --classic boost-asio boost-system --triplet ${{ matrix.vcpkg_triplet }}" >> "$GITHUB_ENV"
278
278
 
279
279
  - name: Build manylinux wheels
280
- uses: pypa/cibuildwheel@v3.4
280
+ uses: pypa/cibuildwheel@v4.1
281
281
 
282
282
  - name: Inspect manylinux wheel dependencies
283
283
  run: |
@@ -218,6 +218,16 @@ __marimo__/
218
218
  .streamlit/secrets.toml
219
219
 
220
220
  # agent-rules (local only)
221
- AGENTS.md
222
- CLAUDE.md
223
- GEMINI.md
221
+ /AGENTS.md
222
+ /CLAUDE.md
223
+ /GEMINI.md
224
+ /.agent-rules/bases/
225
+ /.codex/skills/investigate-bug/
226
+ /.claude/skills/investigate-bug/
227
+ /.codex/skills/review-change/
228
+ /.claude/skills/review-change/
229
+ /.codex/skills/validate-change/
230
+ /.claude/skills/validate-change/
231
+ /.codex/skills/prepare-commit/
232
+ /.claude/skills/prepare-commit/
233
+
@@ -2,6 +2,43 @@
2
2
 
3
3
  All notable changes to Wirestead Python are documented in this file.
4
4
 
5
+ ## v0.9.4
6
+
7
+ Released against Wirestead C++ core v0.9.4.
8
+
9
+ ### Added
10
+
11
+ - `stats()` and `reset_stats()` on every transport, returning a `RuntimeStats`
12
+ snapshot with the full set of counters: bytes and messages accepted, sent and
13
+ received; failed sends; dropped bytes and messages; backpressure events;
14
+ queued, pending and peak queue bytes; and whether backpressure is currently
15
+ active.
16
+
17
+ The C++ core has carried these since before the Python package existed, but
18
+ none of it was bound, so Python callers could configure
19
+ `backpressure_strategy` and subscribe to `on_backpressure` while having no way
20
+ to read the result. That gap was worst under `BackpressureStrategy.BestEffort`,
21
+ where the callback is not a reliable loss signal: dropping is what holds the
22
+ queue below the threshold that would fire it, so a server discarding hundreds
23
+ of megabytes can report `backpressure_events == 0` throughout. Discarded data
24
+ had no observable signal at all from Python. `dropped_bytes` and
25
+ `dropped_messages` now provide one.
26
+
27
+ ## v0.9.3
28
+
29
+ Release aligned with Wirestead C++ core 0.9.3.
30
+
31
+ No Python API changed. The core it binds to did: sustained throughput on the
32
+ Jetson Orin Nano rose 2.3x to 5.2x on TCP and UDS for payloads from 64 B to
33
+ 4 KiB, from draining several queued buffers into one scatter-gather write
34
+ instead of one send syscall per message, and the receive path no longer
35
+ allocates per delivered message. Both reach Python users by rebuilding against
36
+ the newer core; nothing in the binding had to change to pick them up.
37
+
38
+ Core v0.9.3 also collapsed the C++ builder return convention, which is a
39
+ breaking change for C++ callers. The Python binding does not use the builder
40
+ API, so it is unaffected.
41
+
5
42
  ## v0.9.2
6
43
 
7
44
  Release aligned with Wirestead C++ core 0.9.2.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wirestead
3
- Version: 0.9.2
3
+ Version: 0.9.4
4
4
  Summary: Cross-platform Python bindings for the Wirestead async C++ communication library
5
5
  Author: Jinwoo Sung
6
6
  License: Apache-2.0
@@ -0,0 +1 @@
1
+ 39344dff01c5a5a0134caf2624cdd492f05d30ea
@@ -0,0 +1 @@
1
+ v0.9.4
@@ -9,6 +9,7 @@
9
9
  #include <future>
10
10
  #include <memory>
11
11
  #include <stop_token>
12
+ #include <string>
12
13
  #include <thread>
13
14
 
14
15
  #include "wirestead/framer/line_framer.hpp"
@@ -138,6 +139,45 @@ PYBIND11_MODULE(_core, m) {
138
139
  .def_property_readonly("message", [](const ErrorContext& self) { return std::string(self.message()); })
139
140
  .def_property_readonly("client_id", &ErrorContext::client_id);
140
141
 
142
+ // RuntimeStats - an immutable snapshot returned by stats(), not a live view.
143
+ //
144
+ // The three families count different layers: *_accepted is what the
145
+ // application handed to the library, *_sent is what the socket wrote, and
146
+ // *_received counts read completions rather than framed messages. Byte totals
147
+ // reconcile between accepted and sent; message counts do not, because queued
148
+ // writes are batched.
149
+ //
150
+ // Under BackpressureStrategy.BestEffort the on_backpressure callback is not a
151
+ // reliable loss signal. Dropping is what holds the queue below the threshold
152
+ // that would fire it, so whether the callback fires at all depends on how the
153
+ // queue happens to cross that threshold - a server dropping hundreds of
154
+ // megabytes can report backpressure_events == 0 throughout. Watch
155
+ // dropped_bytes and dropped_messages instead.
156
+ py::class_<RuntimeStats>(m, "RuntimeStats")
157
+ .def_readonly("bytes_accepted", &RuntimeStats::bytes_accepted)
158
+ .def_readonly("messages_accepted", &RuntimeStats::messages_accepted)
159
+ .def_readonly("bytes_sent", &RuntimeStats::bytes_sent)
160
+ .def_readonly("messages_sent", &RuntimeStats::messages_sent)
161
+ .def_readonly("bytes_received", &RuntimeStats::bytes_received)
162
+ .def_readonly("messages_received", &RuntimeStats::messages_received)
163
+ .def_readonly("failed_sends", &RuntimeStats::failed_sends)
164
+ .def_readonly("dropped_messages", &RuntimeStats::dropped_messages)
165
+ .def_readonly("dropped_bytes", &RuntimeStats::dropped_bytes)
166
+ .def_readonly("backpressure_events", &RuntimeStats::backpressure_events)
167
+ .def_readonly("queued_bytes", &RuntimeStats::queued_bytes)
168
+ .def_readonly("pending_bytes", &RuntimeStats::pending_bytes)
169
+ .def_readonly("max_queued_bytes", &RuntimeStats::max_queued_bytes)
170
+ .def_readonly("backpressure_active", &RuntimeStats::backpressure_active)
171
+ .def("__repr__", [](const RuntimeStats& self) {
172
+ return "<RuntimeStats accepted=" + std::to_string(self.bytes_accepted) + "B/" +
173
+ std::to_string(self.messages_accepted) + " sent=" + std::to_string(self.bytes_sent) + "B/" +
174
+ std::to_string(self.messages_sent) + " received=" + std::to_string(self.bytes_received) + "B/" +
175
+ std::to_string(self.messages_received) + " dropped=" + std::to_string(self.dropped_bytes) + "B/" +
176
+ std::to_string(self.dropped_messages) + " queued=" + std::to_string(self.queued_bytes) +
177
+ "B peak=" + std::to_string(self.max_queued_bytes) +
178
+ "B backpressure=" + (self.backpressure_active ? "active" : "inactive") + ">";
179
+ });
180
+
141
181
  // Framer
142
182
  py::class_<framer::IFramer, std::shared_ptr<framer::IFramer>>(m, "IFramer");
143
183
 
@@ -190,6 +230,16 @@ PYBIND11_MODULE(_core, m) {
190
230
  return self.send_blocking(data);
191
231
  })
192
232
  .def("connected", &TcpClient::connected)
233
+ .def("stats",
234
+ [](TcpClient& self) {
235
+ py::gil_scoped_release release;
236
+ return self.stats();
237
+ })
238
+ .def("reset_stats",
239
+ [](TcpClient& self) {
240
+ py::gil_scoped_release release;
241
+ self.reset_stats();
242
+ })
193
243
  .def("auto_start", &TcpClient::auto_start, py::arg("start") = true)
194
244
  .def("retry_interval", &TcpClient::retry_interval)
195
245
  .def("max_retries", &TcpClient::max_retries)
@@ -330,6 +380,16 @@ PYBIND11_MODULE(_core, m) {
330
380
  .def("client_count", &TcpServer::client_count)
331
381
  .def("connected_clients", &TcpServer::connected_clients)
332
382
  .def("listening", &TcpServer::listening)
383
+ .def("stats",
384
+ [](TcpServer& self) {
385
+ py::gil_scoped_release release;
386
+ return self.stats();
387
+ })
388
+ .def("reset_stats",
389
+ [](TcpServer& self) {
390
+ py::gil_scoped_release release;
391
+ self.reset_stats();
392
+ })
333
393
  .def(
334
394
  "auto_start", [](TcpServer& self, bool start) -> TcpServer& { return self.auto_start(start); },
335
395
  py::arg("start") = true, py::return_value_policy::reference_internal)
@@ -459,6 +519,16 @@ PYBIND11_MODULE(_core, m) {
459
519
  })
460
520
  .def("send_line", &Serial::send_line)
461
521
  .def("connected", &Serial::connected)
522
+ .def("stats",
523
+ [](Serial& self) {
524
+ py::gil_scoped_release release;
525
+ return self.stats();
526
+ })
527
+ .def("reset_stats",
528
+ [](Serial& self) {
529
+ py::gil_scoped_release release;
530
+ self.reset_stats();
531
+ })
462
532
  .def("auto_start", &Serial::auto_start, py::arg("start") = true)
463
533
  .def("baud_rate", &Serial::baud_rate)
464
534
  .def("data_bits", &Serial::data_bits)
@@ -574,6 +644,16 @@ PYBIND11_MODULE(_core, m) {
574
644
  })
575
645
  .def("send_line", &UdsClient::send_line)
576
646
  .def("connected", &UdsClient::connected)
647
+ .def("stats",
648
+ [](UdsClient& self) {
649
+ py::gil_scoped_release release;
650
+ return self.stats();
651
+ })
652
+ .def("reset_stats",
653
+ [](UdsClient& self) {
654
+ py::gil_scoped_release release;
655
+ self.reset_stats();
656
+ })
577
657
  .def("auto_start", &UdsClient::auto_start, py::arg("start") = true)
578
658
  .def("retry_interval", &UdsClient::retry_interval)
579
659
  .def("max_retries", &UdsClient::max_retries)
@@ -692,6 +772,16 @@ PYBIND11_MODULE(_core, m) {
692
772
  .def("client_count", &UdsServer::client_count)
693
773
  .def("connected_clients", &UdsServer::connected_clients)
694
774
  .def("listening", &UdsServer::listening)
775
+ .def("stats",
776
+ [](UdsServer& self) {
777
+ py::gil_scoped_release release;
778
+ return self.stats();
779
+ })
780
+ .def("reset_stats",
781
+ [](UdsServer& self) {
782
+ py::gil_scoped_release release;
783
+ self.reset_stats();
784
+ })
695
785
  .def("auto_start", &UdsServer::auto_start, py::arg("start") = true)
696
786
  .def("idle_timeout", &UdsServer::idle_timeout)
697
787
  .def("max_clients", &UdsServer::max_clients)
@@ -821,6 +911,16 @@ PYBIND11_MODULE(_core, m) {
821
911
  return self.send_line(line);
822
912
  })
823
913
  .def("connected", &UdpClient::connected)
914
+ .def("stats",
915
+ [](UdpClient& self) {
916
+ py::gil_scoped_release release;
917
+ return self.stats();
918
+ })
919
+ .def("reset_stats",
920
+ [](UdpClient& self) {
921
+ py::gil_scoped_release release;
922
+ self.reset_stats();
923
+ })
824
924
  .def("auto_start", &UdpClient::auto_start, py::arg("start") = true)
825
925
  .def(
826
926
  "use_line_framer",
@@ -937,6 +1037,16 @@ PYBIND11_MODULE(_core, m) {
937
1037
  .def("client_count", &UdpServer::client_count)
938
1038
  .def("connected_clients", &UdpServer::connected_clients)
939
1039
  .def("listening", &UdpServer::listening)
1040
+ .def("stats",
1041
+ [](UdpServer& self) {
1042
+ py::gil_scoped_release release;
1043
+ return self.stats();
1044
+ })
1045
+ .def("reset_stats",
1046
+ [](UdpServer& self) {
1047
+ py::gil_scoped_release release;
1048
+ self.reset_stats();
1049
+ })
940
1050
  .def("auto_start", &UdpServer::auto_start, py::arg("start") = true)
941
1051
  .def("idle_timeout", &UdpServer::idle_timeout)
942
1052
  .def("max_clients", &UdpServer::max_clients)
@@ -0,0 +1,56 @@
1
+ # API
2
+
3
+ The Python package exposes the pybind11 API migrated from the Wirestead C++ core
4
+ repository.
5
+
6
+ ```python
7
+ import wirestead
8
+
9
+ client = wirestead.TcpClient("127.0.0.1", 9000)
10
+ server = wirestead.TcpServer(9000)
11
+ ```
12
+
13
+ The compiled extension is installed as `wirestead._core`.
14
+
15
+ ## Runtime statistics
16
+
17
+ Every transport exposes `stats()`, which returns a `RuntimeStats` snapshot, and
18
+ `reset_stats()`, which zeroes the counters. The snapshot is a copy taken at the
19
+ moment of the call, so holding on to one and taking another later gives you a
20
+ delta.
21
+
22
+ ```python
23
+ stats = server.stats()
24
+ print(stats.bytes_received, stats.dropped_bytes, stats.backpressure_active)
25
+ ```
26
+
27
+ | Field | Meaning |
28
+ |---|---|
29
+ | `bytes_accepted`, `messages_accepted` | What the application handed to the library |
30
+ | `bytes_sent`, `messages_sent` | What the socket actually wrote |
31
+ | `bytes_received`, `messages_received` | Read completions, not framed messages |
32
+ | `failed_sends` | Sends the library refused |
33
+ | `dropped_bytes`, `dropped_messages` | Discarded under `BackpressureStrategy.BestEffort` |
34
+ | `backpressure_events` | Congestion transitions observed |
35
+ | `queued_bytes`, `pending_bytes` | Currently outstanding |
36
+ | `max_queued_bytes` | High-water mark |
37
+ | `backpressure_active` | Whether congestion is on right now |
38
+
39
+ Two things are worth knowing before you read the numbers.
40
+
41
+ Byte totals reconcile between `*_accepted` and `*_sent`, but the message counts
42
+ do not, because queued writes are batched into fewer, larger socket writes.
43
+ `*_received` counts read completions for the same reason, so comparing it
44
+ against your own framed-message count is how you see framing at work.
45
+
46
+ Under `BackpressureStrategy.BestEffort`, `on_backpressure` is not a reliable
47
+ loss signal. Dropping is what holds the queue below the threshold that would
48
+ fire the callback, so whether it fires at all depends on how the queue happens
49
+ to cross that threshold: a server discarding hundreds of megabytes can report
50
+ `backpressure_events == 0` the whole time. Watch `dropped_bytes` and
51
+ `dropped_messages` instead. Under the `Reliable` default the callback does fire
52
+ and nothing is dropped.
53
+
54
+ A server's `stats()` aggregates its live sessions, so the counters fall back to
55
+ zero once every client has disconnected. Keep your own totals if you need
56
+ numbers that survive connection churn.
@@ -15,6 +15,8 @@ The current release line is validated against:
15
15
 
16
16
  | Wirestead Python | Validated Wirestead core refs |
17
17
  |---|---|
18
+ | 0.9.4 | v0.9.4 |
19
+ | 0.9.3 | v0.9.3 |
18
20
  | 0.9.2 | v0.9.2 |
19
21
  | 0.9.1 | v0.9.1 |
20
22
  | 0.9.0 | v0.9.0 |
@@ -1,7 +1,7 @@
1
1
  [build-system]
2
2
  requires = [
3
3
  "scikit-build-core>=0.8",
4
- "pybind11>=2.13,<3",
4
+ "pybind11>=2.13,<4",
5
5
  ]
6
6
  build-backend = "scikit_build_core.build"
7
7
 
@@ -0,0 +1 @@
1
+ __version__ = "0.9.4"
@@ -17,12 +17,86 @@ def test_core_api_surface():
17
17
  "ErrorCode",
18
18
  "LineFramer",
19
19
  "PacketFramer",
20
+ "RuntimeStats",
20
21
  ]
21
22
 
22
23
  missing = [name for name in expected if not hasattr(wirestead, name)]
23
24
  assert not missing
24
25
 
25
26
 
27
+ RUNTIME_STATS_FIELDS = (
28
+ "bytes_accepted",
29
+ "messages_accepted",
30
+ "bytes_sent",
31
+ "messages_sent",
32
+ "bytes_received",
33
+ "messages_received",
34
+ "failed_sends",
35
+ "dropped_messages",
36
+ "dropped_bytes",
37
+ "backpressure_events",
38
+ "queued_bytes",
39
+ "pending_bytes",
40
+ "max_queued_bytes",
41
+ "backpressure_active",
42
+ )
43
+
44
+
45
+ def test_every_transport_exposes_stats():
46
+ import wirestead
47
+
48
+ transports = (
49
+ wirestead.TcpClient,
50
+ wirestead.TcpServer,
51
+ wirestead.Serial,
52
+ wirestead.UdsClient,
53
+ wirestead.UdsServer,
54
+ wirestead.UdpClient,
55
+ wirestead.UdpServer,
56
+ )
57
+
58
+ missing = [
59
+ f"{cls.__name__}.{name}"
60
+ for cls in transports
61
+ for name in ("stats", "reset_stats")
62
+ if not hasattr(cls, name)
63
+ ]
64
+ assert not missing
65
+
66
+
67
+ def test_runtime_stats_snapshot_has_every_counter():
68
+ import wirestead
69
+
70
+ # Constructing does not connect, so nothing has moved yet.
71
+ stats = wirestead.TcpClient("127.0.0.1", 65535).stats()
72
+
73
+ assert isinstance(stats, wirestead.RuntimeStats)
74
+
75
+ missing = [name for name in RUNTIME_STATS_FIELDS if not hasattr(stats, name)]
76
+ assert not missing
77
+
78
+ assert stats.bytes_accepted == 0
79
+ assert stats.bytes_sent == 0
80
+ assert stats.bytes_received == 0
81
+ assert stats.dropped_bytes == 0
82
+ assert stats.backpressure_events == 0
83
+ assert stats.backpressure_active is False
84
+
85
+ assert "RuntimeStats" in repr(stats)
86
+
87
+
88
+ def test_runtime_stats_fields_are_read_only():
89
+ import pytest
90
+ import wirestead
91
+
92
+ stats = wirestead.TcpClient("127.0.0.1", 65535).stats()
93
+
94
+ with pytest.raises(AttributeError):
95
+ stats.bytes_sent = 123
96
+ with pytest.raises(AttributeError):
97
+ stats.backpressure_active = True
98
+
99
+
26
100
  def test_standard_python_surface_uses_canonical_names():
27
101
  import wirestead
28
102
 
@@ -0,0 +1,63 @@
1
+ import json
2
+ import re
3
+ import runpy
4
+ from pathlib import Path
5
+
6
+ PROJECT_ROOT = Path(__file__).resolve().parents[1]
7
+
8
+
9
+ def test_vcpkg_manifest_matches_package_version():
10
+ package_version = runpy.run_path(
11
+ str(PROJECT_ROOT / "src" / "wirestead" / "_version.py")
12
+ )["__version__"]
13
+ manifest = json.loads((PROJECT_ROOT / "vcpkg.json").read_text(encoding="utf-8"))
14
+
15
+ assert manifest["version-string"] == package_version
16
+
17
+
18
+ def test_core_ref_is_a_single_tag():
19
+ core_ref = (PROJECT_ROOT / "WIRESTEAD_CORE_REF").read_text(encoding="ascii")
20
+ lines = core_ref.splitlines()
21
+
22
+ assert len(lines) == 1
23
+ assert lines[0] == lines[0].strip()
24
+ assert lines[0].startswith("v")
25
+
26
+
27
+ def test_vcpkg_baseline_is_a_single_full_commit_sha():
28
+ baseline = (PROJECT_ROOT / "VCPKG_BASELINE").read_text(encoding="ascii")
29
+ lines = baseline.splitlines()
30
+
31
+ assert len(lines) == 1
32
+ assert lines[0] == lines[0].strip()
33
+ # A branch name or short SHA here would silently reintroduce the drift the
34
+ # pin exists to prevent, so require a full 40-character commit SHA.
35
+ assert re.fullmatch(r"[0-9a-f]{40}", lines[0])
36
+
37
+
38
+ def test_core_ref_matches_the_version_this_release_claims_to_bind():
39
+ """The pin and the compatibility table have to agree.
40
+
41
+ WIRESTEAD_CORE_REF is what CI actually checks out and builds against, while
42
+ docs/compatibility.md is what users read. Nothing tied them together, so
43
+ 0.9.3 shipped a wheel built against the v0.9.2 core while the table claimed
44
+ v0.9.3 - green CI throughout, because every existing check looked at the
45
+ version strings and none looked at the pin.
46
+ """
47
+ package_version = runpy.run_path(
48
+ str(PROJECT_ROOT / "src" / "wirestead" / "_version.py")
49
+ )["__version__"]
50
+ core_ref = (PROJECT_ROOT / "WIRESTEAD_CORE_REF").read_text(encoding="ascii").strip()
51
+
52
+ table = (PROJECT_ROOT / "docs" / "compatibility.md").read_text(encoding="utf-8")
53
+ rows = dict(
54
+ re.findall(r"^\|\s*([0-9][^|\s]*)\s*\|\s*(v[^|\s]*)\s*\|", table, re.M)
55
+ )
56
+
57
+ assert package_version in rows, (
58
+ f"docs/compatibility.md has no validated-core row for {package_version}"
59
+ )
60
+ assert rows[package_version] == core_ref, (
61
+ f"WIRESTEAD_CORE_REF is {core_ref} but docs/compatibility.md says "
62
+ f"{package_version} was validated against {rows[package_version]}"
63
+ )
@@ -52,6 +52,50 @@ def test_tcp_server_loopback_smoke():
52
52
  server.stop()
53
53
 
54
54
 
55
+ @pytest.mark.integration
56
+ def test_tcp_server_runtime_stats_track_traffic():
57
+ if not RUN_LOOPBACK_TESTS:
58
+ pytest.skip(
59
+ "set WIRESTEAD_PYTHON_RUN_LOOPBACK_TESTS=1 to enable real transport loopback tests"
60
+ )
61
+
62
+ import wirestead
63
+
64
+ port = reserve_tcp_port()
65
+ server = wirestead.TcpServer(port)
66
+ payload = b"stats-probe\n"
67
+
68
+ try:
69
+ server.bind_address("127.0.0.1")
70
+ assert server.start() is True
71
+ assert wait_until(server.listening)
72
+
73
+ with socket.create_connection(("127.0.0.1", port), timeout=3.0) as peer:
74
+ peer.settimeout(3.0)
75
+ assert wait_until(lambda: server.client_count() == 1)
76
+
77
+ assert server.stats().bytes_accepted == 0
78
+
79
+ assert server.broadcast(payload)
80
+ assert peer.recv(1024) == payload
81
+ peer.sendall(payload)
82
+ assert wait_until(lambda: server.stats().bytes_received >= len(payload))
83
+
84
+ stats = server.stats()
85
+ assert stats.bytes_accepted >= len(payload)
86
+ assert stats.messages_accepted >= 1
87
+ assert stats.bytes_received >= len(payload)
88
+ assert stats.dropped_bytes == 0
89
+ assert stats.failed_sends == 0
90
+
91
+ # The counters are a snapshot, so an earlier one keeps its values.
92
+ server.reset_stats()
93
+ assert server.stats().bytes_accepted == 0
94
+ assert stats.bytes_accepted >= len(payload)
95
+ finally:
96
+ server.stop()
97
+
98
+
55
99
  @pytest.mark.integration
56
100
  def test_tcp_client_loopback_smoke():
57
101
  if not RUN_LOOPBACK_TESTS:
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wirestead-python",
3
- "version-string": "0.9.2",
3
+ "version-string": "0.9.4",
4
4
  "dependencies": [
5
5
  "wirestead"
6
6
  ]
@@ -1 +0,0 @@
1
- 6d9d7df564a1ccdaa994e4ad39ccd4a32360867b
@@ -1 +0,0 @@
1
- v0.9.2
@@ -1,13 +0,0 @@
1
- # API
2
-
3
- The Python package exposes the pybind11 API migrated from the Wirestead C++ core
4
- repository.
5
-
6
- ```python
7
- import wirestead
8
-
9
- client = wirestead.TcpClient("127.0.0.1", 9000)
10
- server = wirestead.TcpServer(9000)
11
- ```
12
-
13
- The compiled extension is installed as `wirestead._core`.
@@ -1 +0,0 @@
1
- __version__ = "0.9.2"
@@ -1,35 +0,0 @@
1
- import json
2
- import re
3
- import runpy
4
- from pathlib import Path
5
-
6
- PROJECT_ROOT = Path(__file__).resolve().parents[1]
7
-
8
-
9
- def test_vcpkg_manifest_matches_package_version():
10
- package_version = runpy.run_path(
11
- str(PROJECT_ROOT / "src" / "wirestead" / "_version.py")
12
- )["__version__"]
13
- manifest = json.loads((PROJECT_ROOT / "vcpkg.json").read_text(encoding="utf-8"))
14
-
15
- assert manifest["version-string"] == package_version
16
-
17
-
18
- def test_core_ref_is_a_single_tag():
19
- core_ref = (PROJECT_ROOT / "WIRESTEAD_CORE_REF").read_text(encoding="ascii")
20
- lines = core_ref.splitlines()
21
-
22
- assert len(lines) == 1
23
- assert lines[0] == lines[0].strip()
24
- assert lines[0].startswith("v")
25
-
26
-
27
- def test_vcpkg_baseline_is_a_single_full_commit_sha():
28
- baseline = (PROJECT_ROOT / "VCPKG_BASELINE").read_text(encoding="ascii")
29
- lines = baseline.splitlines()
30
-
31
- assert len(lines) == 1
32
- assert lines[0] == lines[0].strip()
33
- # A branch name or short SHA here would silently reintroduce the drift the
34
- # pin exists to prevent, so require a full 40-character commit SHA.
35
- assert re.fullmatch(r"[0-9a-f]{40}", lines[0])
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