Skip to content

fix(server): correct MessageData annotations and materialize dynamic fields (#49)#80

Open
ff225 wants to merge 1 commit into
mainfrom
fix/sciot-049-message-data-typing
Open

fix(server): correct MessageData annotations and materialize dynamic fields (#49)#80
ff225 wants to merge 1 commit into
mainfrom
fix/sciot-049-message-data-typing

Conversation

@ff225

@ff225 ff225 commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • MessageData's core field annotations didn't match runtime types: device_id/message_id are str (decoded from bytes in inference_protocol.py), message_content is a dict, and timestamp is a float (<d in the wire format), not int/str as declared.
  • The post-decode attributes (received_timestamp, avg_speed, latency, synthetic_latency, payload_size, offloading_layer_index, layer_output, device_layers_inference_time, device_cpu_percent) were unannotated class variables, so @dataclass never turned them into real fields even though every caller treats them as instance state.

Scoped to the typing-correctness part of #49 (annotations + materializing the dynamic attributes as fields). Left get_latency's string-coercing signature and the broader "adopt TypedDict/slots for recurring config structures" follow-up out of scope — no single obvious target and no behavior change needed there.

Note: payload stays str — the only construction site (inference_protocol.py) always passes "" and no code reads message_data.payload, so there's no evidence it's ever actually bytes today; flagging in case that's stale intent from before the protocol refactor.

Test plan

  • tests/unit/test_message_data.py: new tests assert the core field annotations match runtime types, the previously-dynamic attributes are real dataclasses.fields, and they default to None.
  • uv run pytest fast suite (217 passed, 1 skipped)
  • ruff check / ruff format --check on changed files

…fields (#49)

device_id/message_id are str (not int), message_content is a dict (not
str), and timestamp is a float (not str) at the only construction site
in inference_protocol.py. The post-decode attributes were also plain
class variables without annotations, so they never became real
dataclass fields despite being treated as instance state everywhere
they're used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant