fix(kernel): include Running in state transitions#211
Open
wysh3 wants to merge 3 commits intomofa-org:mainfrom
Open
fix(kernel): include Running in state transitions#211wysh3 wants to merge 3 commits intomofa-org:mainfrom
wysh3 wants to merge 3 commits intomofa-org:mainfrom
Conversation
Running state existed but was excluded from is_active() causing agents in Running state to be reported as inactive. can_transition_to() also had no transitions defined for Running, making it unreachable from Ready. Changes: - is_active() now returns true for Running state - Added transitions: Ready->Running, Running->Paused, Running->Executing, Running->ShuttingDown, Running->Error, Running->Failed - Added test_agent_state_running_transitions covering all new transitions - Added test_agent_state_is_active covering all states
Collaborator
|
Hi : cargo clippy --workspace --all-features -- -D errors Please verify this. If you confirm the code is correct, just leave a comment, and we will merge it and test it ourselves. |
Contributor
Author
|
@lijingrs Just merged the latest from main, now all checks are passing now. Feel free to merge and test whenever you're ready, and let me know if you spot any issues! |
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.
Summary
AgentState::Runningexisted as a valid state variant but was excluded fromis_active()and had zero transitions defined incan_transition_to(). This PRfixes both gaps and adds test coverage.
Motivation
Agents in the
Runningstate were incorrectly reported as inactive byis_active(), which only checked forReadyandExecuting. Additionally, anycall to
state.transition_to(AgentState::Running)would always returnAgentError::invalid_state_transitionbecause the state machine had notransitions defined for
Running— making it unreachable via the public APIdespite being a valid enum variant used by the runtime.
Changes
mofa-kernel: UpdatedAgentState::is_active()to returntrueforRunning(in addition toReadyandExecuting)mofa-kernel: Added 6 missing transitions tocan_transition_to():Ready → RunningRunning → PausedRunning → ExecutingRunning → ShuttingDownRunning → Error(_)Running → Failedmofa-kernel: Addedtest_agent_state_running_transitions(12 assertionscovering valid/invalid transitions and
transition_to()return values)mofa-kernel: Addedtest_agent_state_is_active(8 assertions coveringall relevant states)
Related Issues
Closes #199
Found during codebase audit —
AgentState::Runningwas defined and handled inDisplaybut missing from the state machine logic.Testing
cargo fmt --check— cleancargo clippy -p mofa-kernel— exit 0, no new warningscargo test -p mofa-kernel— 82 passed, 0 failedChecklist
cargo fmt --checkpassescargo clippypasses with no warningscargo testpasses