From 48e1ffd7ec954c2b0fe38e41dcbaba014206360e Mon Sep 17 00:00:00 2001 From: mrsolusdev Date: Fri, 28 Aug 2026 18:40:51 +0500 Subject: [PATCH] chore: rename veyron -> vynkor, remove legacy aliases - LICENSE veyron-core -> vynkor-core - vynkor/errors.py: Veyron* -> Vynkor* only, removed 9 legacy aliases + __all__ entries (breaking) - vynkor/{framing,client,concurrent,confirmation_gate,plugin}.py: Veyron* -> Vynkor* - tests, fuzz, examples: Veyron -> Vynkor - README.md: errors section Vynkor only - verified: grep -R veyron -> 0, py_compile OK --- LICENSE | 2 +- README.md | 8 ++-- examples/echo_plugin.py | 2 +- fuzz/fuzz_framing.py | 6 +-- tests/test_framing_compressed.py | 6 +-- tests/test_framing_mac.py | 4 +- tests/test_publish_event.py | 6 +-- tests/test_sdk.py | 2 +- tests/test_send_action.py | 8 ++-- vynkor/client.py | 64 ++++++++++++++++---------------- vynkor/concurrent.py | 6 +-- vynkor/confirmation_gate.py | 14 +++---- vynkor/errors.py | 38 +++++++++---------- vynkor/framing.py | 62 +++++++++++++++---------------- vynkor/plugin.py | 4 +- 15 files changed, 116 insertions(+), 116 deletions(-) diff --git a/LICENSE b/LICENSE index f3092cd..5ceee7f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2026 veyron-core +Copyright (c) 2026 vynkor-core Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index fe98b80..fa277d0 100644 --- a/README.md +++ b/README.md @@ -250,10 +250,10 @@ Other client methods: `recv()` / `recv_frame()` / `recv_timeout(timeout)`, All SDK-level failures raise `vynkor.VynkorError` (or a subclass) instead of bare `ValueError` / `RuntimeError` / `TimeoutError`. Subclasses mirror the -Rust `WireError` variants: `VeyronIoError`, `VeyronProtoError`, -`VeyronFrameMagicMismatch`, `VeyronFrameCrcMismatch`, `VeyronFrameReadTimeout`, -`VeyronPayloadTooLarge`, `VeyronTimeout`, `VeyronPermissionDenied`, -`VeyronInternal`. +Rust `WireError` variants: `VynkorIoError`, `VynkorProtoError`, +`VynkorFrameMagicMismatch`, `VynkorFrameCrcMismatch`, `VynkorFrameReadTimeout`, +`VynkorPayloadTooLarge`, `VynkorTimeout`, `VynkorPermissionDenied`, +`VynkorInternal`. ## Development diff --git a/examples/echo_plugin.py b/examples/echo_plugin.py index 08695c7..e051990 100644 --- a/examples/echo_plugin.py +++ b/examples/echo_plugin.py @@ -1,4 +1,4 @@ -"""Lightweight demo plugin for the Veyron Python SDK. +"""Lightweight demo plugin for the Vynkor Python SDK. Shows: lifecycle hooks, manifest declaration, action handling (plain, streaming, and publish-from-plugin), event subscription, and SessionClose diff --git a/fuzz/fuzz_framing.py b/fuzz/fuzz_framing.py index e9520bd..2deedd9 100644 --- a/fuzz/fuzz_framing.py +++ b/fuzz/fuzz_framing.py @@ -18,7 +18,7 @@ with atheris.instrument_imports(): from vynkor.framing import read_frame - from vynkor.errors import VeyronError + from vynkor.errors import VynkorError FIXED_KEY = bytes(range(32)) @@ -26,12 +26,12 @@ def test_one_input(data: bytes) -> None: try: read_frame(io.BytesIO(data)) - except VeyronError: + except VynkorError: pass # rejecting malformed input is expected, correct behavior try: read_frame(io.BytesIO(data), session_key=FIXED_KEY) - except VeyronError: + except VynkorError: pass diff --git a/tests/test_framing_compressed.py b/tests/test_framing_compressed.py index d4076ea..bb31deb 100644 --- a/tests/test_framing_compressed.py +++ b/tests/test_framing_compressed.py @@ -21,7 +21,7 @@ pack_frame, read_frame, ) -from vynkor.errors import VeyronInternal +from vynkor.errors import VynkorInternal def _pack_compressed_frame(target: str, plain_payload: bytes, session_key=None) -> bytes: @@ -67,7 +67,7 @@ def test_read_frame_rejects_bad_mac_on_compressed_frame(): wrong_key = derive_session_key(b"different", b"nonce123", "plugin-a") payload = b"y" * 100_000 frame = _pack_compressed_frame("kernel", payload, session_key=session_key) - with pytest.raises(VeyronInternal, match="MAC"): + with pytest.raises(VynkorInternal, match="MAC"): read_frame(io.BytesIO(frame), session_key=wrong_key) @@ -85,5 +85,5 @@ def test_read_frame_rejects_garbage_compressed_payload(): target_bytes = b"kernel".ljust(32, b"\x00")[:32] crc = crc32(garbage) & 0xFFFFFFFF header = struct.pack(HEADER_FMT, MAGIC, FLAG_COMPRESSED, len(garbage), target_bytes, crc) - with pytest.raises(VeyronInternal): + with pytest.raises(VynkorInternal): read_frame(io.BytesIO(header + garbage)) diff --git a/tests/test_framing_mac.py b/tests/test_framing_mac.py index 68332e7..9f3ae7e 100644 --- a/tests/test_framing_mac.py +++ b/tests/test_framing_mac.py @@ -14,7 +14,7 @@ async_read_frame, HEADER_SIZE, ) -from vynkor.errors import VeyronInternal +from vynkor.errors import VynkorInternal def test_derive_session_key_is_deterministic(): @@ -97,7 +97,7 @@ def test_read_frame_mac_rejects_tampered(): payload = b"round trip" frame = bytearray(pack_frame("tgt", payload, session_key=key)) frame[-1] ^= 0xFF # corrupt last byte of MAC tag - with pytest.raises(VeyronInternal, match="MAC verification failed"): + with pytest.raises(VynkorInternal, match="MAC verification failed"): read_frame(io.BytesIO(bytes(frame)), session_key=key) diff --git a/tests/test_publish_event.py b/tests/test_publish_event.py index cf97d07..a852b60 100644 --- a/tests/test_publish_event.py +++ b/tests/test_publish_event.py @@ -9,7 +9,7 @@ import pytest from vynkor import VynkorClient -from vynkor.errors import VeyronInternal, VeyronTimeout +from vynkor.errors import VynkorInternal, VynkorTimeout from vynkor.framing import pack_frame, read_frame from vynkor.vynkor_protocol_pb2 import ( Envelope, @@ -94,7 +94,7 @@ def kernel(): t = threading.Thread(target=kernel) t.start() - with pytest.raises(VeyronInternal): + with pytest.raises(VynkorInternal): await client.publish_event("my.event", b"{}", 1000) t.join() @@ -110,7 +110,7 @@ def kernel(): t = threading.Thread(target=kernel) t.start() start = time.monotonic() - with pytest.raises(VeyronTimeout): + with pytest.raises(VynkorTimeout): await client.publish_event("my.event", b"{}", 150) elapsed = time.monotonic() - start assert elapsed < 2.0 diff --git a/tests/test_sdk.py b/tests/test_sdk.py index d3cc624..8132bd5 100644 --- a/tests/test_sdk.py +++ b/tests/test_sdk.py @@ -1,4 +1,4 @@ -"""Integration tests for the Python Veyron SDK. +"""Integration tests for the Python Vynkor SDK. Requires a running kernel (vyn start --foreground) at /tmp/vyn.sock. Run with: pytest tests/ -v diff --git a/tests/test_send_action.py b/tests/test_send_action.py index da6d8f3..c6fe44f 100644 --- a/tests/test_send_action.py +++ b/tests/test_send_action.py @@ -9,7 +9,7 @@ import pytest from vynkor import VynkorClient -from vynkor.errors import VeyronInternal, VeyronTimeout +from vynkor.errors import VynkorInternal, VynkorTimeout from vynkor.framing import pack_frame, read_frame from vynkor.vynkor_protocol_pb2 import ( Envelope, @@ -76,7 +76,7 @@ def kernel(): t = threading.Thread(target=kernel) t.start() - with pytest.raises(VeyronInternal): + with pytest.raises(VynkorInternal): await client.send_action("get_weather", b"{}", 1000) t.join() @@ -94,7 +94,7 @@ def kernel(): t = threading.Thread(target=kernel) t.start() - with pytest.raises(VeyronInternal): + with pytest.raises(VynkorInternal): await client.send_action("get_weather", b"{}", 1000) t.join() @@ -110,7 +110,7 @@ def kernel(): t = threading.Thread(target=kernel) t.start() start = time.monotonic() - with pytest.raises(VeyronTimeout): + with pytest.raises(VynkorTimeout): await client.send_action("get_weather", b"{}", 150) elapsed = time.monotonic() - start assert elapsed < 2.0 diff --git a/vynkor/client.py b/vynkor/client.py index 401d096..d7bbfbd 100644 --- a/vynkor/client.py +++ b/vynkor/client.py @@ -21,10 +21,10 @@ from typing import Callable, Optional from .errors import ( - VeyronInternal, - VeyronPayloadTooLarge, - VeyronProtoError, - VeyronTimeout, + VynkorInternal, + VynkorPayloadTooLarge, + VynkorProtoError, + VynkorTimeout, ) from .framing import ( FLAG_FRAGMENTED, @@ -194,7 +194,7 @@ async def connect_ws( import websockets import websockets.exceptions except ImportError as e: - raise VeyronInternal( + raise VynkorInternal( "websockets package required for WebSocket transport: pip install vynkor-sdk[websockets] or websockets>=12" ) from e @@ -280,10 +280,10 @@ async def register_full( self._apply_session_nonce(plugin_id, nonce) return ack if response.HasField("error"): - raise VeyronInternal( + raise VynkorInternal( f"registration rejected: {response.error.message} ({response.error.details})" ) - raise VeyronInternal("expected PluginRegisterAck") + raise VynkorInternal("expected PluginRegisterAck") # ── Sending ───────────────────────────────────────────────────── @@ -304,7 +304,7 @@ async def send_raw_with_flags(self, target: str, extra_flags: int, payload: byte """ if self._is_ws(): if len(payload) > MAX_PAYLOAD: - raise VeyronPayloadTooLarge(len(payload)) + raise VynkorPayloadTooLarge(len(payload)) # Never compress over WS; MAC still applies frame = pack_frame( target, payload, flags=extra_flags, session_key=self.session_key, compress=False @@ -312,7 +312,7 @@ async def send_raw_with_flags(self, target: str, extra_flags: int, payload: byte try: await self._ws.send(frame) # type: ignore[union-attr] except Exception as e: - raise VeyronInternal(f"websocket send failed: {e}") from e + raise VynkorInternal(f"websocket send failed: {e}") from e else: frame = pack_frame(target, payload, flags=extra_flags, session_key=self.session_key) assert self._writer is not None, "not connected" @@ -329,14 +329,14 @@ async def send_fragmented(self, target: str, payload: bytes, chunk_size: int) -> so this raises on a WebSocket transport. """ if self._is_ws(): - raise VeyronInternal("fragmented frames are not supported over WebSocket (R5-03)") + raise VynkorInternal("fragmented frames are not supported over WebSocket (R5-03)") if len(payload) > MAX_PAYLOAD: - raise VeyronPayloadTooLarge(len(payload)) + raise VynkorPayloadTooLarge(len(payload)) if chunk_size <= 0 or chunk_size + FRAG_HEADER_SIZE > MAX_PAYLOAD: - raise VeyronInternal(f"invalid fragment chunk_size: {chunk_size}") + raise VynkorInternal(f"invalid fragment chunk_size: {chunk_size}") total = max(1, -(-len(payload) // chunk_size)) # ceil div if total > 0xFFFF: - raise VeyronInternal(f"payload needs {total} fragments; max is 65535") + raise VynkorInternal(f"payload needs {total} fragments; max is 65535") stream_id = self._next_stream_id self._next_stream_id = (self._next_stream_id + 1) & 0xFFFFFFFF or 1 @@ -377,7 +377,7 @@ async def _ws_recv_frame(self): except Exception as e: # Map websocket close/error to Io-like error so callers see # disconnect / EOF, matching UDS behavior - raise VeyronInternal(f"websocket connection closed: {e}") from e + raise VynkorInternal(f"websocket connection closed: {e}") from e # websockets may deliver str for text frames — ignore them (kernel # gateway never sends them as traffic, per Rust docs) if isinstance(data, str): @@ -389,21 +389,21 @@ async def _ws_recv_frame(self): async def recv(self) -> Envelope: flags, payload = await self.recv_frame() if flags & FLAG_RAW_BINARY: - raise VeyronInternal("received raw-binary frame; use recv_frame() for audio") + raise VynkorInternal("received raw-binary frame; use recv_frame() for audio") env = Envelope() try: env.ParseFromString(payload) except Exception as e: - raise VeyronProtoError(str(e)) from e + raise VynkorProtoError(str(e)) from e return env async def recv_timeout(self, timeout: float) -> Envelope: """Receive and decode the next Envelope, bounded by ``timeout`` seconds. - Raises VeyronTimeout if nothing arrives in time.""" + Raises VynkorTimeout if nothing arrives in time.""" try: return await asyncio.wait_for(self.recv(), timeout=timeout) except asyncio.TimeoutError: - raise VeyronTimeout() from None + raise VynkorTimeout() from None def _prune_reassembly(self) -> None: """Stale sets can't pin memory forever.""" @@ -421,18 +421,18 @@ def _absorb_fragment(self, flags: int, payload: bytes): complete, else ``None``. Mirrors the Rust SDK's ``absorb_fragment``.""" hdr = parse_frag_header(payload) if hdr is None: - raise VeyronInternal("fragment header too short") + raise VynkorInternal("fragment header too short") _fragment_id, seq, total, stream_id = hdr if total == 0 or seq >= total: - raise VeyronInternal(f"invalid fragment header: seq {seq} / total {total}") + raise VynkorInternal(f"invalid fragment header: seq {seq} / total {total}") buf = self._reassembly.get(stream_id) if buf is not None: if buf.total != total: del self._reassembly[stream_id] - raise VeyronInternal("fragment total mismatch within stream") + raise VynkorInternal("fragment total mismatch within stream") elif len(self._reassembly) >= MAX_REASSEMBLY_STREAMS: - raise VeyronInternal("too many concurrent fragment streams") + raise VynkorInternal("too many concurrent fragment streams") else: buf = _ReassemblyBuf(total, flags & ~(FLAG_FRAGMENTED | FLAG_MAC_PRESENT)) self._reassembly[stream_id] = buf @@ -442,7 +442,7 @@ def _absorb_fragment(self, flags: int, payload: bytes): new_total = buf.buffered_bytes - replaced_len + len(chunk) if new_total > MAX_PAYLOAD: del self._reassembly[stream_id] - raise VeyronPayloadTooLarge(MAX_PAYLOAD + 1) + raise VynkorPayloadTooLarge(MAX_PAYLOAD + 1) buf.buffered_bytes = new_total buf.fragments[seq] = chunk @@ -478,7 +478,7 @@ async def publish_event( ) -> EventPublishAck: """Publish an event to the kernel event bus. Requires ``PERMISSION_EVENT_PUBLISH``. ``timeout_ms == 0`` uses the kernel default of - 30s. Raises ``VeyronInternal`` on a kernel Error envelope, ``VeyronTimeout`` on + 30s. Raises ``VynkorInternal`` on a kernel Error envelope, ``VynkorTimeout`` on deadline expiry. The returned ``EventPublishAck`` is returned as-is regardless of its status field — callers inspect ``ack.status`` themselves, mirroring the Rust SDK.""" @@ -494,7 +494,7 @@ async def publish_event( lambda r: r.HasField("event_publish_ack") or r.HasField("error"), ) if resp.HasField("error"): - raise VeyronInternal( + raise VynkorInternal( f"kernel error: {resp.error.message} ({resp.error.details})" ) return resp.event_publish_ack @@ -504,8 +504,8 @@ async def send_action( ) -> ActionResponse: """Ask the kernel to perform an action and await its ``ActionResponse``. ``timeout_ms == 0`` uses the kernel default of 30s. Raises - ``VeyronInternal`` on a kernel Error envelope or an ActionStreamAbort for - this ``action_id``, ``VeyronTimeout`` on deadline expiry.""" + ``VynkorInternal`` on a kernel Error envelope or an ActionStreamAbort for + this ``action_id``, ``VynkorTimeout`` on deadline expiry.""" action_id = _next_action_id() env = Envelope() env.action_request.CopyFrom(ActionRequest( @@ -527,11 +527,11 @@ async def send_action( or r.HasField("error"), ) if resp.HasField("error"): - raise VeyronInternal( + raise VynkorInternal( f"kernel error: {resp.error.message} ({resp.error.details})" ) if resp.HasField("action_stream_abort"): - raise VeyronInternal(f"stream aborted: {resp.action_stream_abort.reason}") + raise VynkorInternal(f"stream aborted: {resp.action_stream_abort.reason}") return resp.action_response async def send_action_streaming(self, action: str, timeout_ms: int = 0) -> str: @@ -585,7 +585,7 @@ async def send_command( response = await self.recv() if response.HasField("kernel_command_ack"): return response.kernel_command_ack - raise VeyronInternal("expected KernelCommandAck") + raise VynkorInternal("expected KernelCommandAck") async def ping(self) -> float: """Round-trip a ``Ping`` to the kernel; returns measured latency in @@ -598,7 +598,7 @@ async def ping(self) -> float: await self.send("kernel", env) response = await self.recv() if not response.HasField("pong"): - raise VeyronInternal("expected Pong") + raise VynkorInternal("expected Pong") return time.monotonic() - t0 # ── Audio ─────────────────────────────────────────────────────── @@ -626,7 +626,7 @@ async def _await_matching( while True: remaining = deadline - time.monotonic() if remaining <= 0: - raise VeyronTimeout() + raise VynkorTimeout() resp = await self.recv_timeout(remaining) if predicate(resp): return resp diff --git a/vynkor/concurrent.py b/vynkor/concurrent.py index 9d4e519..dfb62ce 100644 --- a/vynkor/concurrent.py +++ b/vynkor/concurrent.py @@ -168,15 +168,15 @@ async def serve_concurrent(client, jwt_token: str, handler: ConcurrentHandler) - Wraps :func:`run_concurrent_loop` with registration; ``jwt_token`` is presented at registration (empty string on unsecured kernels). A - rejected registration raises :class:`vynkor.errors.VeyronPermissionDenied`. + rejected registration raises :class:`vynkor.errors.VynkorPermissionDenied`. """ - from .errors import VeyronPermissionDenied + from .errors import VynkorPermissionDenied ack = await client.register_full( handler.id(), handler.version(), handler.manifest(), jwt_token ) if not ack.accepted: - raise VeyronPermissionDenied(f"registration rejected: {ack.reject_reason}") + raise VynkorPermissionDenied(f"registration rejected: {ack.reject_reason}") try: await handler.on_init(client) except BaseException: diff --git a/vynkor/confirmation_gate.py b/vynkor/confirmation_gate.py index 7432a40..7d4cc72 100644 --- a/vynkor/confirmation_gate.py +++ b/vynkor/confirmation_gate.py @@ -423,7 +423,7 @@ async def send_confirmation_request(client, op: str, params_json: bytes) -> str: Invokes ``request_`` and returns the ``pending_id`` the plugin assigned. Raises on non-OK status or missing ``pending_id``. """ - from .errors import VeyronInternal + from .errors import VynkorInternal resp = await client.send_action(f"request_{op}", params_json, 0) # ActionStatus.ACTION_OK == 1 (proto3 renumbered: 0 is UNKNOWN) @@ -433,17 +433,17 @@ async def send_confirmation_request(client, op: str, params_json: bytes) -> str: from .vynkor_protocol_pb2 import ActionStatus as _AS if resp.status != _AS.ACTION_OK: - raise VeyronInternal(f"request_{op} failed: {resp.error}") + raise VynkorInternal(f"request_{op} failed: {resp.error}") except ImportError: if resp.status != 1: - raise VeyronInternal(f"request_{op} failed: {resp.error}") + raise VynkorInternal(f"request_{op} failed: {resp.error}") try: value = json.loads(resp.data_json) if resp.data_json else {} except Exception as e: - raise VeyronInternal(f"invalid pending response: {e}") from e + raise VynkorInternal(f"invalid pending response: {e}") from e pid = value.get("pending_id") if isinstance(value, dict) else None if not isinstance(pid, str) or not pid: - raise VeyronInternal("pending response missing pending_id") + raise VynkorInternal("pending response missing pending_id") return pid @@ -453,10 +453,10 @@ async def send_confirmation(client, op: str, pending_id: str): Invokes ``confirm_`` with ``pending_id``. Returns the provider's ``ActionResponse`` as-is — inspect ``.status`` / ``.error`` yourself. """ - from .errors import VeyronInternal + from .errors import VynkorInternal try: params = json.dumps({"pending_id": pending_id}).encode() except Exception as e: - raise VeyronInternal(f"failed to encode confirm params: {e}") from e + raise VynkorInternal(f"failed to encode confirm params: {e}") from e return await client.send_action(f"confirm_{op}", params, 0) diff --git a/vynkor/errors.py b/vynkor/errors.py index 77128e3..2c6dc08 100644 --- a/vynkor/errors.py +++ b/vynkor/errors.py @@ -7,31 +7,31 @@ class VynkorError(Exception): - """Base class for every Veyron SDK error (mirrors `WireError`).""" + """Base class for every Vynkor SDK error (mirrors `WireError`).""" -class VeyronIoError(VynkorError): +class VynkorIoError(VynkorError): """Underlying I/O failure (mirrors `WireError::Io`).""" -class VeyronProtoError(VynkorError): +class VynkorProtoError(VynkorError): """Protobuf encode/decode failure (mirrors `WireError::Proto`).""" -class VeyronFrameMagicMismatch(VynkorError): +class VynkorFrameMagicMismatch(VynkorError): """Frame magic != 0x5652 (mirrors `WireError::FrameMagicMismatch`).""" -class VeyronFrameCrcMismatch(VynkorError): +class VynkorFrameCrcMismatch(VynkorError): """Frame CRC32 mismatch (mirrors `WireError::FrameCrcMismatch`).""" -class VeyronFrameReadTimeout(VynkorError): +class VynkorFrameReadTimeout(VynkorError): """Timed out reading a frame body once it started (mirrors `WireError::FrameReadTimeout`).""" -class VeyronPayloadTooLarge(VynkorError): +class VynkorPayloadTooLarge(VynkorError): """Payload exceeds the protocol limit (mirrors `WireError::PayloadTooLarge`).""" def __init__(self, size: int): @@ -39,14 +39,14 @@ def __init__(self, size: int): super().__init__(f"payload too large: {size} bytes") -class VeyronTimeout(VynkorError): +class VynkorTimeout(VynkorError): """Operation timed out (mirrors `WireError::Timeout`).""" def __init__(self, message: str = "operation timed out"): super().__init__(message) -class VeyronPermissionDenied(VynkorError): +class VynkorPermissionDenied(VynkorError): """Permission denied; message carries the reason (mirrors `WireError::PermissionDenied`).""" @@ -54,7 +54,7 @@ def __init__(self, message: str): super().__init__(f"permission denied: {message}") -class VeyronInternal(VynkorError): +class VynkorInternal(VynkorError): """Internal/protocol error; message carries details (mirrors `WireError::Internal`).""" @@ -64,13 +64,13 @@ def __init__(self, message: str): __all__ = [ "VynkorError", - "VeyronIoError", - "VeyronProtoError", - "VeyronFrameMagicMismatch", - "VeyronFrameCrcMismatch", - "VeyronFrameReadTimeout", - "VeyronPayloadTooLarge", - "VeyronTimeout", - "VeyronPermissionDenied", - "VeyronInternal", + "VynkorIoError", + "VynkorProtoError", + "VynkorFrameMagicMismatch", + "VynkorFrameCrcMismatch", + "VynkorFrameReadTimeout", + "VynkorPayloadTooLarge", + "VynkorTimeout", + "VynkorPermissionDenied", + "VynkorInternal", ] diff --git a/vynkor/framing.py b/vynkor/framing.py index 7a090ae..611a522 100644 --- a/vynkor/framing.py +++ b/vynkor/framing.py @@ -8,12 +8,12 @@ import zstandard from .errors import ( - VeyronFrameCrcMismatch, - VeyronFrameMagicMismatch, - VeyronFrameReadTimeout, - VeyronInternal, - VeyronIoError, - VeyronPayloadTooLarge, + VynkorFrameCrcMismatch, + VynkorFrameMagicMismatch, + VynkorFrameReadTimeout, + VynkorInternal, + VynkorIoError, + VynkorPayloadTooLarge, ) MAGIC = 0x5652 @@ -116,9 +116,9 @@ def _decompress(payload: bytes) -> bytes: try: out = decompressor.decompress(payload, max_output_size=MAX_PAYLOAD) except zstandard.ZstdError as e: - raise VeyronInternal(f"decompress frame: {e}") from e + raise VynkorInternal(f"decompress frame: {e}") from e if len(out) > MAX_PAYLOAD: - raise VeyronPayloadTooLarge(len(out)) + raise VynkorPayloadTooLarge(len(out)) return out @@ -139,7 +139,7 @@ def pack_frame( rejects FLAG_COMPRESSED inbound, so the WS path never compresses). """ if len(payload) > MAX_PAYLOAD: - raise VeyronPayloadTooLarge(len(payload)) + raise VynkorPayloadTooLarge(len(payload)) if session_key is not None: flags |= FLAG_MAC_PRESENT @@ -190,29 +190,29 @@ def read_frame(stream, session_key: Optional[bytes] = None) -> bytes: not a live socket — use async_read_frame for that.""" header_bytes = stream.read(HEADER_SIZE) if len(header_bytes) < HEADER_SIZE: - raise VeyronIoError("truncated frame header") + raise VynkorIoError("truncated frame header") magic, flags, length, target_bytes, stored_crc = struct.unpack(HEADER_FMT, header_bytes) if magic != MAGIC: - raise VeyronFrameMagicMismatch() + raise VynkorFrameMagicMismatch() if length > MAX_PAYLOAD: - raise VeyronPayloadTooLarge(length) + raise VynkorPayloadTooLarge(length) payload = stream.read(length) if length > 0 else b"" if len(payload) < length: - raise VeyronIoError("truncated frame payload") + raise VynkorIoError("truncated frame payload") computed = crc32(payload) & 0xFFFFFFFF if computed != stored_crc: - raise VeyronFrameCrcMismatch() + raise VynkorFrameCrcMismatch() flags, header_bytes, payload = _normalize(flags, target_bytes, payload) if flags & FLAG_MAC_PRESENT: tag = stream.read(32) if len(tag) < 32: - raise VeyronIoError("truncated MAC tag") + raise VynkorIoError("truncated MAC tag") if session_key is not None and not verify_tag(session_key, header_bytes, payload, tag): - raise VeyronInternal("frame MAC verification failed") + raise VynkorInternal("frame MAC verification failed") elif session_key is not None: - raise VeyronInternal("MAC missing on secured connection") + raise VynkorInternal("MAC missing on secured connection") return payload @@ -229,29 +229,29 @@ def read_frame_from_bytes(data: bytes, session_key: Optional[bytes] = None): stream = io.BytesIO(data) header_bytes = stream.read(HEADER_SIZE) if len(header_bytes) < HEADER_SIZE: - raise VeyronIoError("truncated frame header") + raise VynkorIoError("truncated frame header") magic, flags, length, target_bytes, stored_crc = struct.unpack(HEADER_FMT, header_bytes) if magic != MAGIC: - raise VeyronFrameMagicMismatch() + raise VynkorFrameMagicMismatch() if length > MAX_PAYLOAD: - raise VeyronPayloadTooLarge(length) + raise VynkorPayloadTooLarge(length) payload = stream.read(length) if length > 0 else b"" if len(payload) < length: - raise VeyronIoError("truncated frame payload") + raise VynkorIoError("truncated frame payload") computed = crc32(payload) & 0xFFFFFFFF if computed != stored_crc: - raise VeyronFrameCrcMismatch() + raise VynkorFrameCrcMismatch() flags, header_bytes2, payload = _normalize(flags, target_bytes, payload) if flags & FLAG_MAC_PRESENT: tag = stream.read(32) if len(tag) < 32: - raise VeyronIoError("truncated MAC tag") + raise VynkorIoError("truncated MAC tag") if session_key is not None and not verify_tag(session_key, header_bytes2, payload, tag): - raise VeyronInternal("frame MAC verification failed") + raise VynkorInternal("frame MAC verification failed") elif session_key is not None: - raise VeyronInternal("MAC missing on secured connection") + raise VynkorInternal("MAC missing on secured connection") return flags, payload @@ -272,25 +272,25 @@ async def _read_body(): header_bytes = first_byte + await reader.readexactly(HEADER_SIZE - 1) magic, flags, length, target_bytes, stored_crc = struct.unpack(HEADER_FMT, header_bytes) if magic != MAGIC: - raise VeyronFrameMagicMismatch() + raise VynkorFrameMagicMismatch() if length > MAX_PAYLOAD: - raise VeyronPayloadTooLarge(length) + raise VynkorPayloadTooLarge(length) payload = await reader.readexactly(length) if length > 0 else b"" computed = crc32(payload) & 0xFFFFFFFF if computed != stored_crc: - raise VeyronFrameCrcMismatch() + raise VynkorFrameCrcMismatch() flags, header_bytes2, payload = _normalize(flags, target_bytes, payload) if flags & FLAG_MAC_PRESENT: tag = await reader.readexactly(32) if session_key is not None and not verify_tag(session_key, header_bytes2, payload, tag): - raise VeyronInternal("frame MAC verification failed") + raise VynkorInternal("frame MAC verification failed") elif session_key is not None: - raise VeyronInternal("MAC missing on secured connection") + raise VynkorInternal("MAC missing on secured connection") return flags, payload try: return await asyncio.wait_for(_read_body(), timeout=frame_timeout) except asyncio.TimeoutError: - raise VeyronFrameReadTimeout() from None + raise VynkorFrameReadTimeout() from None diff --git a/vynkor/plugin.py b/vynkor/plugin.py index 17589f7..b5abf1c 100644 --- a/vynkor/plugin.py +++ b/vynkor/plugin.py @@ -11,7 +11,7 @@ from typing import Optional from .client import VynkorClient -from .errors import VynkorError, VeyronPermissionDenied +from .errors import VynkorError, VynkorPermissionDenied from .vynkor_protocol_pb2 import Envelope, Event, PluginManifest, Pong @@ -143,7 +143,7 @@ async def serve(self, client: VynkorClient, jwt_token: str) -> None: self._client = client ack = await client.register_full(self.id(), self.version(), self.manifest(), jwt_token) if not ack.accepted: - raise VeyronPermissionDenied(f"registration rejected: {ack.reject_reason}") + raise VynkorPermissionDenied(f"registration rejected: {ack.reject_reason}") try: await self.on_init(client)