Skip to content

Refactor: name task lifecycle flags accurately - #1415

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:refactor/task-lifecycle-flags
Jul 21, 2026
Merged

Refactor: name task lifecycle flags accurately#1415
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:refactor/task-lifecycle-flags

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Rename the slot-local ready_state bitmask to lifecycle_flags in both A2A3 runtimes.
  • Consolidate ready, completion, deferred, and propagation bit definitions into lifecycle flag enums.
  • Keep bit values, atomic ordering, layout, and profiling accounting unchanged.

Related Issues

Rename the shared slot bitmask and consolidate its flag enums. Keep both A2A3 runtime variants aligned without changing layout, ordering, or atomic behavior.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the task lifecycle state management in the runtime. It consolidates several individual enums (PTO2ReadyState, PTO2CompletionFlag, PTO2DeferredCompletionFlag, and PTO2DispatchPropagationFlag) into a single unified enum PTO2TaskLifecycleFlag using bitwise flags. Additionally, the atomic member variable ready_state in PTO2TaskSlotState has been renamed to lifecycle_flags to better reflect its consolidated purpose. All corresponding references, documentation, and unit tests have been updated accordingly. There are no review comments to address, and we have no further feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change replaces ready_state and separate lifecycle flag enums with a unified atomic lifecycle_flags bitfield, updates scheduler ready-slot claiming and profiling accounting, and aligns runtime documentation and wiring tests with the new state representation.

Changes

Lifecycle Flag Consolidation

Layer / File(s) Summary
Unify slot lifecycle state
src/a2a3/runtime/.../pto_runtime2_types.h
PTO2TaskLifecycleFlag replaces separate flag enums; slot methods and reuse reset now operate on lifecycle_flags.
Route ready slots with lifecycle claims
src/a2a3/runtime/.../scheduler/pto_scheduler.h
Ready-slot CAS loops and profiling attribution use lifecycle flags instead of ready_state.
Align wiring validation and runtime documentation
tests/ut/cpp/a2a3/test_wiring.cpp, src/a2a3/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md
Tests and early-candidate documentation reference lifecycle flags and their reset behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Poem

A bunny hops through flags anew,
One atomic keeps the lifecycle true.
Ready, done, deferred bits align,
Reset clears the state in time.
The scheduler claims its prize—
Clean little bits beneath the skies.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main refactor: renaming and consolidating task lifecycle flags.
Description check ✅ Passed The description matches the changeset and accurately summarizes the refactor and preserved behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/a2a3/runtime/host_build_graph/runtime/pto_runtime2_types.h (1)

469-474: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Align PTO2TaskLifecycleFlag bits with the parent runtime.

To fully satisfy the PR objective of aligning both A2A3 runtime variants, consider adding PTO2_DISPATCH_PROPAGATED = 1U << 3 to this enum. Even if it's currently unused in the host_build_graph fork, explicitly reserving this bit guarantees exact layout parity with tensormap_and_ringbuffer and prevents accidental reuse of the 1U << 3 bit for a different flag in the future.

💡 Proposed change
 enum PTO2TaskLifecycleFlag : uint8_t {
     PTO2_LIFECYCLE_FLAGS_NONE = 0,
     PTO2_READY_CLAIMED = 1U << 0,
     PTO2_COMPLETION_DONE = 1U << 1,
     PTO2_SUBTASK_DEFERRED = 1U << 2,
+    PTO2_DISPATCH_PROPAGATED = 1U << 3,
 };
🤖 Prompt for 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.

In `@src/a2a3/runtime/host_build_graph/runtime/pto_runtime2_types.h` around lines
469 - 474, Add PTO2_DISPATCH_PROPAGATED with value 1U << 3 to
PTO2TaskLifecycleFlag, preserving the existing flag values and reserving the bit
for layout parity with the parent runtime.
🤖 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.

Nitpick comments:
In `@src/a2a3/runtime/host_build_graph/runtime/pto_runtime2_types.h`:
- Around line 469-474: Add PTO2_DISPATCH_PROPAGATED with value 1U << 3 to
PTO2TaskLifecycleFlag, preserving the existing flag values and reserving the bit
for layout parity with the parent runtime.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 214314ba-1761-436e-ae2e-b751bfd9611e

📥 Commits

Reviewing files that changed from the base of the PR and between 32fc376 and b0f9515.

📒 Files selected for processing (6)
  • src/a2a3/runtime/host_build_graph/runtime/pto_runtime2_types.h
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/pto_scheduler.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2_types.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/pto_scheduler.h
  • tests/ut/cpp/a2a3/test_wiring.cpp

@ChaoWao
ChaoWao merged commit 0a0262c into hw-native-sys:main Jul 21, 2026
28 of 29 checks passed
@ChaoWao
ChaoWao deleted the refactor/task-lifecycle-flags branch July 21, 2026 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant