https://github.com/coldbricks/hearback
Listener-side output re-validation decorator against schema/predicate.
https://github.com/coldbricks/hearback
coldbricks decorator output-validation pypi python typed validation zero-dependency
Last synced: 14 days ago
JSON representation
Listener-side output re-validation decorator against schema/predicate.
- Host: GitHub
- URL: https://github.com/coldbricks/hearback
- Owner: coldbricks
- License: mit
- Created: 2026-07-22T19:20:33.000Z (18 days ago)
- Default Branch: main
- Last Pushed: 2026-07-22T19:20:38.000Z (18 days ago)
- Last Synced: 2026-07-24T05:05:19.198Z (16 days ago)
- Topics: coldbricks, decorator, output-validation, pypi, python, typed, validation, zero-dependency
- Language: Python
- Homepage: https://pypi.org/project/hearback/
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# hearback
[](https://pypi.org/project/hearback/)
[](https://pypi.org/project/hearback/)
[](https://github.com/coldbricks/hearback/actions)
[](LICENSE)
Listener-side counterpart to echo-confirmation: a decorator that re-validates function outputs against a schema or predicate before they leave the call boundary.
## Install
```bash
pip install hearback
```
## Quickstart
```python
from hearback import hearback, HearbackError
@hearback(lambda n: isinstance(n, int) and n >= 0)
def absolute_delta(a, b):
return abs(a - b)
assert absolute_delta(3, 10) == 7
@hearback(str)
def label(x):
return x
assert label("ok") == "ok"
try:
label(123)
except HearbackError:
pass
```
## Why this exists
- Enforce output contracts at the function boundary
- Accept a callable predicate or a type / tuple of types
- Surface failures as `HearbackError` with the bad value
## API
| Symbol | Description |
|--------|-------------|
| `hearback(predicate)` | Decorator; predicate is callable or type |
| `HearbackError` | Raised when output fails re-validation |
## Related packages
Part of the coldbricks micro-library suite (small, typed, zero-dependency helpers):
| Package | Role |
|---------|------|
| [`buzzkill`](https://github.com/coldbricks/buzzkill) | Guaranteed shutdown callbacks |
| [`aftercare`](https://github.com/coldbricks/aftercare) | Reverse-order teardown |
| [`fluffer`](https://github.com/coldbricks/fluffer) | Startup pre-warm |
| [`edging`](https://github.com/coldbricks/edging) | Token-bucket rate limit |
| [`readback`](https://github.com/coldbricks/readback) | Echo-confirmation validation |
| **hearback** | Output re-validation decorator |
| [`agecheck`](https://github.com/coldbricks/agecheck) | Timezone-correct age thresholds |
| [`transponder`](https://github.com/coldbricks/transponder) | State broadcast on change |
## Development
```bash
pip install -e ".[dev]"
pytest -q
ruff check .
mypy src
```
## Roadmap
This is an early **0.1.0** release (Alpha) with active development planned:
- JSON Schema / pydantic integration
- Async function support
- Structured advisory payloads on failure
## License
MIT © Coldbricks — coldbricks@gmail.com