Test: mirror a2a3 scope-guard regression to a5 and fix stale TMR docs - #1752
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe pull request adds scope-mode tracking and layout assertions to A2A3 and A5 runtime tests. It adds coverage for default and manual ChangesRuntime scope behavior and documentation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
17948bd to
b3c1d05
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/ut/cpp/a2a3/test_a2a3_fatal.cpp`:
- Line 53: Update the static layout assertions near FakeRuntime in
tests/ut/cpp/a2a3/test_a2a3_fatal.cpp:53-53 and
tests/ut/cpp/a5/test_a5_fatal.cpp:47-47 to compare
FakeRuntime::pending_scope_mode’s offset directly with
PTO2Runtime::pending_scope_mode, preserving the production runtime layout
contract used by PTO2ScopeGuard.
In `@tests/ut/cpp/a5/test_a5_fatal.cpp`:
- Around line 183-206: Update the setup in
ScopeGuardForwardsModeUntilLexicalScopeExit to initialize
runtime.pending_scope_mode to PTO2ScopeMode::MANUAL before the first
PTO2_SCOPE_GUARD(); retain the existing assertion that the default guard
forwards PTO2ScopeMode::AUTO.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ea5b98df-86e6-4624-a406-59b782871a97
📒 Files selected for processing (5)
src/a2a3/runtime/tensormap_and_ringbuffer/docs/MULTI_RING.mdsrc/a2a3/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.mdsrc/a5/runtime/tensormap_and_ringbuffer/docs/MULTI_RING.mdtests/ut/cpp/a2a3/test_a2a3_fatal.cpptests/ut/cpp/a5/test_a5_fatal.cpp
b3c1d05 to
99587c8
Compare
Close the two P4/P5 residuals flagged in hw-native-sys#1582's 2026-08-09 re-audit (after hw-native-sys#1718 landed): R1 — a5 lacked the scope-guard regression test that a2a3 gained in hw-native-sys#1718. a5's `PTO2_SCOPE_GUARD(...)` has been variadic (and its MANUAL path live, read by `rt_scope_begin` -> `begin_scope(mode)`) since the hw-native-sys#1100 import, but `ut-a5` would not have caught a regression in MANUAL forwarding. Mirror `ScopeGuardForwardsModeUntilLexicalScopeExit` to `test_a5_fatal.cpp`: `FakeRuntime` gains `pending_scope_mode` (immediately after `ops`, the prefix the inline wrappers pun through) and `last_scope_mode`; `fake_scope_begin` records the mode; the test asserts AUTO then MANUAL forwarding across lexical scope exit. Both test files also extend the single `offsetof(ops) == 0` guard to a second one pinning `pending_scope_mode` at `offsetof(PTO2Runtime, pending_scope_mode)`, directly asserting the fake matches the production `PTO2Runtime` prefix layout the inline wrappers pun through (not just pointer size). Both tests also seed `pending_scope_mode = PTO2ScopeMode::MANUAL` before the first guard so the `AUTO` assertion actually verifies the guard writes the default, rather than reading a pre-existing `AUTO` from the member initializer. R2 — a2a3 `RUNTIME_LOGIC.md` still described the retained temp buffer as a single runner-owned instance, but the shared host-runtime callback `get_retained_temp_buffer(runner_ctx, pipeline_slot, ...)` is per-slot and a5's matching paragraph already says so. Align a2a3 to a5's wording ("each slot's buffer lives on the runner"). Also fix a stale accessor location in both trees' `MULTI_RING.md`: `PTO2TaskId`'s direct accessors live in `src/common/task_interface/pto_task_id.h`, not `pto_runtime2_types.h`. Verification: built and ran `test_a2a3_fatal` and `test_a5_fatal` — 4/4 tests pass each (including the new a5 ScopeGuard case); both files are clang-format clean (ColumnLimit 120).
Summary
Closes the two P4/P5 residuals flagged in #1582's 2026-08-09 re-audit (after #1718 landed).
R1 — a5 lacked the scope-guard regression test that a2a3 gained in #1718
a5's
PTO2_SCOPE_GUARD(...)has been variadic (and its MANUAL path live —rt_scope_beginreadspending_scope_modeand forwards it tobegin_scope(mode)) since the #1100 import, butut-a5would not catch a regression in MANUAL forwarding. MirroredScopeGuardForwardsModeUntilLexicalScopeExittotests/ut/cpp/a5/test_a5_fatal.cpp:FakeRuntimegainspending_scope_mode(immediately afterops, the prefix the inline wrappers pun through) andlast_scope_mode.fake_scope_beginrecords the forwarded mode.Both test files also extend the single
offsetof(FakeRuntime, ops) == 0guard to a second one pinningpending_scope_modeatsizeof(PTO2RuntimeOps *), since thereinterpret_castnow depends on the two-field{ops, pending_scope_mode}prefix, not one.R2 — a2a3
RUNTIME_LOGIC.mdretained-buffer wording was stalea2a3 described the retained temp buffer as a single runner-owned instance, but the shared host-runtime callback
get_retained_temp_buffer(runner_ctx, pipeline_slot, ...)is per-slot and a5's matching paragraph already says so. Aligned a2a3 to a5's wording ("each slot's buffer lives on the runner").Bonus — stale accessor location in both trees'
MULTI_RING.mdPTO2TaskId's direct accessors live insrc/common/task_interface/pto_task_id.h, notpto_runtime2_types.h. Fixed in both a2a3 and a5.Test plan
cmake -S tests/ut/cpp -B build_ut -G Ninjathencmake --build build_ut --target test_a2a3_fatal test_a5_fatal— both compile clean../build_ut/test_a2a3_fatal— 4/4 passed (incl.A2A3Fatal.ScopeGuardForwardsModeUntilLexicalScopeExit)../build_ut/test_a5_fatal— 4/4 passed (incl. newA5Fatal.ScopeGuardForwardsModeUntilLexicalScopeExit).ut-a2a3/ut-a5green.Refs #1582.