From c306fa5c68d1f9e86f968e316ed07b27363f8604 Mon Sep 17 00:00:00 2001 From: medeirosdev Date: Sun, 28 Dec 2025 15:29:29 -0300 Subject: [PATCH 1/3] chore: prepare v0.2.0 release with Hybrid Mode --- CHANGELOG.md | 25 +++++++++++++++++++++++++ pyproject.toml | 2 +- src/trueentropy/__init__.py | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a33d25b..551063f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,31 @@ All notable changes to TrueEntropy will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.0] - 2025-12-28 + +### Added + +#### Hybrid Mode +- `configure(mode="HYBRID")` - Switch to high-performance PRNG mode +- `HybridTap` class - PRNG seeded by true entropy from the pool +- `hybrid_reseed_interval` config - Control reseed frequency (default: 60s) +- 83x faster than DIRECT mode (~5M ops/sec vs ~60K ops/sec) + +#### Architecture Improvements +- `BaseTap` abstract class - Common interface for tap implementations +- `get_tap()` function - Get current tap instance (EntropyTap or HybridTap) +- Mode switching via `configure(mode="DIRECT"|"HYBRID")` + +#### Documentation +- ARCHITECTURE.md updated with Operation Modes section and diagrams +- README.md updated with Hybrid Mode usage and tuning guidelines +- Comprehensive demo script in `examples/demo_comprehensive.py` + +### Changed +- `EntropyTap` now inherits from `BaseTap` +- Global `_tap` can now be either `EntropyTap` or `HybridTap` +- `configure()` now supports `mode` and `hybrid_reseed_interval` parameters + ## [0.1.1] - 2025-12-27 ### Added diff --git a/pyproject.toml b/pyproject.toml index fb01525..b26aaba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "trueentropy" -version = "0.1.1" +version = "0.2.0" description = "True randomness from real-world entropy sources - harness chaos from network latency, system jitter, seismic activity, and financial markets" readme = "README.md" license = "MIT" diff --git a/src/trueentropy/__init__.py b/src/trueentropy/__init__.py index 36e9908..dbe64f0 100644 --- a/src/trueentropy/__init__.py +++ b/src/trueentropy/__init__.py @@ -40,7 +40,7 @@ # ----------------------------------------------------------------------------- # Version Information # ----------------------------------------------------------------------------- -__version__ = "0.1.1" +__version__ = "0.2.0" __author__ = "TrueEntropy Contributors" __license__ = "MIT" From a920a2ca92506ef7c3ebc70a6e4a9b8ff20fc7e2 Mon Sep 17 00:00:00 2001 From: medeirosdev Date: Sun, 28 Dec 2025 15:32:40 -0300 Subject: [PATCH 2/3] style: fix all ruff lint errors in tests --- tests/test_harvesters_live.py | 4 ++-- tests/test_integration.py | 5 ++--- tests/test_pool.py | 3 +-- tests/test_tap.py | 3 +-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/test_harvesters_live.py b/tests/test_harvesters_live.py index 0ef8f5a..604a8a3 100644 --- a/tests/test_harvesters_live.py +++ b/tests/test_harvesters_live.py @@ -185,7 +185,7 @@ def test_timing_consistency(self) -> None: harvester = TimingHarvester(num_samples=32) results = [] - for i in range(5): + for _ in range(5): result = harvester.collect() results.append(result.data) time.sleep(0.01) # Small delay between samples @@ -428,7 +428,7 @@ def test_external_source_toggles(self) -> None: @pytest.fixture(scope="session", autouse=True) -def final_report(request): +def final_report(): """Print final performance report after all tests complete.""" yield diff --git a/tests/test_integration.py b/tests/test_integration.py index f1a05af..4607d18 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -10,11 +10,10 @@ # - End-to-end random number generation # # ============================================================================= +"""Integration tests for the TrueEntropy library.""" from __future__ import annotations -"""Integration tests for the TrueEntropy library.""" - import time @@ -148,7 +147,7 @@ def test_feed_affects_pool(self) -> None: import trueentropy # Get current health - before = trueentropy.health() + _ = trueentropy.health() # Capture initial state (unused but validates call) # Feed a lot of data for _ in range(10): diff --git a/tests/test_pool.py b/tests/test_pool.py index 17fdd16..b8989ed 100644 --- a/tests/test_pool.py +++ b/tests/test_pool.py @@ -11,11 +11,10 @@ # - Edge cases # # ============================================================================= +"""Tests for the EntropyPool class.""" from __future__ import annotations -"""Tests for the EntropyPool class.""" - import threading import time diff --git a/tests/test_tap.py b/tests/test_tap.py index 39c8121..358480d 100644 --- a/tests/test_tap.py +++ b/tests/test_tap.py @@ -12,11 +12,10 @@ # - Distribution uniformity # # ============================================================================= +"""Tests for the EntropyTap class.""" from __future__ import annotations -"""Tests for the EntropyTap class.""" - import math from collections import Counter From e259953de1ecc0f07cac9e1b069c0a2d536f4c70 Mon Sep 17 00:00:00 2001 From: medeirosdev Date: Sun, 28 Dec 2025 15:37:38 -0300 Subject: [PATCH 3/3] fix(tests): reset config in test_get_tap for test isolation --- tests/test_integration.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/test_integration.py b/tests/test_integration.py index 4607d18..474f6f3 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -171,13 +171,18 @@ def test_get_pool(self) -> None: assert isinstance(pool, EntropyPool) def test_get_tap(self) -> None: - """get_tap() should return EntropyTap.""" + """get_tap() should return a BaseTap instance (EntropyTap or HybridTap).""" import trueentropy - from trueentropy.tap import EntropyTap + from trueentropy.config import reset_config + from trueentropy.tap import BaseTap + + # Reset to default DIRECT mode to ensure consistent test state + reset_config() + trueentropy.configure(mode="DIRECT") tap = trueentropy.get_tap() - assert isinstance(tap, EntropyTap) + assert isinstance(tap, BaseTap) class TestBackgroundCollector: