Skip to content

Stamp capture time explicitly (four-slot timestamp model) - #7

Merged
mbreissi merged 1 commit into
mainfrom
feat/capture-timestamps
Jul 27, 2026
Merged

Stamp capture time explicitly (four-slot timestamp model)#7
mbreissi merged 1 commit into
mainfrom
feat/capture-timestamps

Conversation

@mbreissi

Copy link
Copy Markdown
Contributor

Implements the SOUTHBOUND four-slot timestamp model (edgecommons/edgecommons#79) for the Modbus adapter: serverTs is the capture time — the moment the protocol read the value. For this direct-client adapter, receive IS capture, so the stamp is taken at register-read completion and passed explicitly through to each sample, never left to the data() facade's serverTs=now-at-publish default (which drifts under batchMs batching). sourceTs stays absent (Modbus supplies no device time); receivedTs is not emitted (degenerate for a direct client).

What was drifting

  • Block-read failures (poll_manager._poll_group): BAD samples for a failed block read carried no server_ts, so the publisher's value-less path stamped them at publish/flush time — drifting by up to the whole batchMs window. Now the failure timestamp is captured when the exception is caught and passed through.
  • Successful reads and decode failures already stamped read_ts at read completion; sb/read replies stamped inline at reply assembly — now captured explicitly at read completion with the same stamp as the poll path.

Changes

  • modbus_adapter/poll_manager.py — capture the failure timestamp on the block-read-failure path and pass it as server_ts.
  • modbus_adapter/command_service.pysb/read captures serverTs at read completion.
  • modbus_adapter/publisher.py — module docstring states the capture-time contract.
  • tests/test_publish_events.py — new test: a delayed batched flush (simulated batching latency) carries the read-time serverTs, not the publish time, for valued and value-less samples; block-read-failure test now pins the capture stamp.
  • docs/reference/messaging-interface.md — one reference paragraph stating the four-slot model in present tense.

Validation

  • Baseline: 130 passed, coverage 95.67% (gate 90%).
  • After: 131 passed, coverage 95.68%.

🤖 Generated with Claude Code

https://claude.ai/code/session_014iQDskU2E1HLStYHoZrSTn

serverTs is the CAPTURE time (edgecommons/edgecommons#79): for a
direct-client Modbus adapter, receive IS capture, so it must be stamped
at register-read completion, not left to the data() facade's
serverTs=now-at-publish default, which drifts under batchMs batching.

- poll_manager: the block-read-failure path now captures the failure
  timestamp when the exception is caught and passes it through as
  server_ts (it previously fell back to publish-time stamping in the
  publisher's value-less path). Successful reads and decode failures
  already stamped read_ts at read completion.
- command_service: sb/read captures serverTs explicitly at read
  completion (same stamp as the poll path) instead of inline at reply
  assembly.
- publisher: docstring states the capture-time contract for every
  poll-path sample; the facade's at-publish default remains only as a
  last-resort fallback.
- tests: a delayed batched flush (simulated batching latency) must
  carry the read-time serverTs, not the publish time, for both valued
  and value-less samples; the block-read-failure test now pins the
  capture stamp.
- docs: reference/messaging-interface.md states the four-slot model
  (serverTs = capture time; sourceTs absent; receivedTs not emitted).

131 tests pass, coverage 95.68% (gate 90%).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014iQDskU2E1HLStYHoZrSTn
@mbreissi
mbreissi changed the base branch from feat/southbound-conformance to main July 27, 2026 16:56
@mbreissi
mbreissi marked this pull request as ready for review July 27, 2026 16:56
@mbreissi
mbreissi merged commit 3bea24c into main Jul 27, 2026
2 checks passed
@mbreissi
mbreissi deleted the feat/capture-timestamps branch July 27, 2026 16:56
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