Files
agents/control-plane/internal/storage/execution_state_validation.go
zeekayandGitHub 5b5cf9e9db feat: merge AgentField control plane + SDKs as Hanzo Agents (#1)
Transforms hanzoai/agents from a marketplace config repo into a full
agent orchestration platform by merging the AgentField infrastructure:

- Go control plane (K8s-like agent orchestration, service mesh, DAG workflows)
- Python SDK (FastAPI-based agent framework, LiteLLM, memory, DID/VC)
- TypeScript SDK (@hanzo/agents - Vercel AI SDK, MCP, workflows)
- Go SDK (idiomatic agent builder + client)
- React 19 embedded dashboard (XyFlow DAGs, Recharts, Radix UI)
- Docker/K8s/Helm deployment configs
- Examples: hello world, deep research, RAG, simulation, benchmarks
- Functional test suite across Python/Go/TypeScript

All references rebranded: AgentField → Hanzo Agents
- Module: github.com/hanzoai/agents/control-plane
- Python: hanzo_agents
- TypeScript: @hanzo/agents
- Go: github.com/hanzoai/agents/sdk/go
- Env vars: HANZO_AGENTS_*
- Config: hanzo-agents.yaml

Previous marketplace configs moved to config/ directory.
2026-02-09 18:53:09 -08:00

57 lines
1.9 KiB
Go

package storage
import (
"fmt"
"github.com/hanzoai/agents/control-plane/pkg/types"
)
type InvalidExecutionStateTransitionError struct {
ExecutionID string
CurrentState string
NewState string
Reason string
}
func (e *InvalidExecutionStateTransitionError) Error() string {
return fmt.Sprintf("invalid execution state transition for %s: cannot change from %s to %s - %s",
e.ExecutionID, e.CurrentState, e.NewState, e.Reason)
}
func validateExecutionStateTransition(currentStatus, newStatus string) error {
currentStatus = types.NormalizeExecutionStatus(currentStatus)
newStatus = types.NormalizeExecutionStatus(newStatus)
validTransitions := map[string][]string{
string(types.ExecutionStatusUnknown): {string(types.ExecutionStatusPending)},
string(types.ExecutionStatusPending): {string(types.ExecutionStatusQueued), string(types.ExecutionStatusRunning), string(types.ExecutionStatusCancelled)},
string(types.ExecutionStatusQueued): {string(types.ExecutionStatusRunning), string(types.ExecutionStatusCancelled)},
string(types.ExecutionStatusRunning): {string(types.ExecutionStatusSucceeded), string(types.ExecutionStatusFailed), string(types.ExecutionStatusCancelled), string(types.ExecutionStatusTimeout)},
string(types.ExecutionStatusSucceeded): {},
string(types.ExecutionStatusFailed): {},
string(types.ExecutionStatusCancelled): {},
string(types.ExecutionStatusTimeout): {},
}
allowedStates, exists := validTransitions[currentStatus]
if !exists {
return fmt.Errorf("unknown current status: %s", currentStatus)
}
for _, allowed := range allowedStates {
if newStatus == allowed {
return nil
}
}
if currentStatus == newStatus {
return nil
}
return &InvalidExecutionStateTransitionError{
CurrentState: currentStatus,
NewState: newStatus,
Reason: "transition not allowed by workflow execution state machine",
}
}