Skip to content

Repository files navigation

readback

PyPI Python Versions CI License: MIT

Validation via echo-confirmation. Send a value, read it back through a confirm function, and fail closed on mismatch — the classic command-then-verify pattern used in safety and control systems.

Install

pip install readback

Quickstart

from readback import readback, ReadbackError

sent = {"motor": "arm", "rpm": 1200}
confirmed = readback(sent, confirm_fn=lambda: {"motor": "arm", "rpm": 1200})
assert confirmed == sent

try:
    readback(sent, confirm_fn=lambda: {"motor": "arm", "rpm": 0})
except ReadbackError as e:
    assert e.expected == sent
    assert e.got["rpm"] == 0

Why this exists

  • Catch write/read skew before acting on a bad state
  • Fail closed with structured expected / got on mismatch
  • Zero dependencies; works anywhere Python runs

API

Symbol Description
readback(value, confirm_fn) Confirm echo matches; return value
ReadbackError Mismatch error with .expected and .got

Related packages

Part of the coldbricks micro-library suite (small, typed, zero-dependency helpers):

Package Role
buzzkill Guaranteed shutdown callbacks
aftercare Reverse-order teardown
fluffer Startup pre-warm
edging Token-bucket rate limit
readback Echo-confirmation validation
hearback Output re-validation decorator
agecheck Timezone-correct age thresholds
transponder State broadcast on change

Development

pip install -e ".[dev]"
pytest -q
ruff check .
mypy src

Roadmap

This is an early 0.1.0 release (Alpha) with active development planned:

  • Tolerance / partial-match policies
  • Async confirm functions
  • Structured logging of mismatch traces

License

MIT © Coldbricks — coldbricks@gmail.com

About

Validation via echo-confirmation: readback(value, confirm_fn).

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages