test(pyamber): add unit tests for six DP-thread state managers#4893
Merged
Conversation
Cover the consume-once / accumulator / alignment contracts for state_processing, exception, console-message, tuple-processing, statistics, and embedded-control-message managers. Issue apache#4891 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4893 +/- ##
============================================
+ Coverage 43.15% 43.77% +0.62%
+ Complexity 2153 2087 -66
============================================
Files 915 957 +42
Lines 32208 34066 +1858
Branches 3256 3753 +497
============================================
+ Hits 13898 14914 +1016
- Misses 17464 18357 +893
+ Partials 846 795 -51
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds focused pytest unit coverage for several DP-thread “manager” components in PyAmber, ensuring core state/metrics/control-message behaviors are pinned and regression-protected.
Changes:
- Added consume-once / slot-clearing contract tests for state, tuple, and exception managers.
- Added statistics aggregation/validation tests, including an
xfail(strict=True)probe for the known negativeidle_timebug. - Added console-buffer and embedded-control-message (ECM) alignment/scope tests across ALL / NO / PORT alignment modes.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| amber/src/main/python/core/architecture/managers/test_state_processing_manager.py | Tests consume-once semantics and independence of input/output state slots. |
| amber/src/main/python/core/architecture/managers/test_exception_manager.py | Tests exception stashing, consume-once read, and history retention behavior. |
| amber/src/main/python/core/architecture/managers/test_tuple_processing_manager.py | Tests consume-once tuple/marker reads plus input-port-id fallback behavior. |
| amber/src/main/python/core/architecture/managers/test_statistics_manager.py | Tests per-port aggregation, validation, processing-time accumulation, and idle-time behavior (incl. xfail probe). |
| amber/src/main/python/core/architecture/managers/test_console_message_manager.py | Tests TimedBuffer-backed console message flushing behavior. |
| amber/src/main/python/core/architecture/managers/test_embedded_control_message_manager.py | Tests ECM alignment modes, cleanup, and scope filtering behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…, fix _make_ecm comment - test_get_without_flush_below_threshold_yields_nothing: pin `print_buf._last_output_time = datetime.now()` right before the assertion so the `>=1s` flush branch can't fire just because the rest of the test ran more than ~1s after construction. - test_get_drains_when_last_output_time_is_stale: drop the unused `monkeypatch` parameter — the test backdates `_last_output_time` directly and never touches `datetime.now`. - _make_ecm: replace the misleading "Reuse the same identity *object* across calls" comment with one that explains what actually happens — fresh EmbeddedControlMessageIdentity instances with id="ecm-1" hash equal under dataclass-style equality, so they aggregate under a single key in `ecm_received`.
aglinxinyuan
approved these changes
May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
Adds pytest specs for six DP-thread state managers under
amber/src/main/python/core/architecture/managers/:state_processing_manager,exception_manager,console_message_manager,tuple_processing_manager,statistics_manager, andembedded_control_message_manager. The specs cover the consume-once read pattern, accumulator validation, force-flush semantics, and the three ECM alignment modes (ALL / NO / PORT) including scope filtering.Pinned a real-but-questionable behavior in
StatisticsManager.get_statistics()whereidle_timegoes negative when data + control processing time overshootstotal_execution_time, paired with anxfail(strict=True)probe asserting the intended>= 0contract.Any related issues, documentation, discussions?
Closes #4891. Bug filed as #4892 (xfail probe will flip to XPASS when fixed).
How was this PR tested?
New pytest cases (44 passing + 1 xfailed) under
core/architecture/managers/. Verified locally withpython -m pytest core/architecture/managers/andruff format --check amber/src/main/python.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.7 (1M context)