Guard hub phase transitions against spurious session events#126
Closed
scion-gteam[bot] wants to merge 1 commit into
Closed
Guard hub phase transitions against spurious session events#126scion-gteam[bot] wants to merge 1 commit into
scion-gteam[bot] wants to merge 1 commit into
Conversation
…events A rapid session.start → session.end sequence from a spurious sciontool could permanently reset an agent's phase even while the agent works normally. This adds two guards: 1. Phase regression guard: rejects transitions that would move an agent backward in its forward-progress lifecycle (e.g. running → starting) in both the status update handler and broker heartbeat handler. 2. Activity-driven phase auto-correction: when an activity that implies the agent is running (working, thinking, executing, etc.) arrives but the phase is pre-running, auto-promotes the phase to running. Fixes #124
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
Fixes #124 — Hub phase stuck at 'starting' after spurious session lifecycle events.
updateAgentStatushandler andhandleBrokerHeartbeathandler that rejects transitions backward in the forward-progress lifecycle (e.g. running → starting). This prevents a spurious session.start/session.end pair from corrupting the agent's phase.Phase.Ordinal(),Phase.IsActivePhase(), andActivity.ImpliesRunning()helpers to the state package to support the guards.Test plan
TestPhaseOrdinal,TestPhaseIsActivePhase,TestActivityImpliesRunningTestAgentStatusUpdate_RejectsPhaseRegression,TestAgentStatusUpdate_ActivityAutoCorrectsPhase,TestBrokerHeartbeat_RejectsPhaseRegressionpkg/agent/statetest suite passes (no regressions)pkg/hubtest suite passes (no regressions — 141s, all existing tests pass)