feat(simulation): add profiles_ready/configuring states and parent_simulation_id/graph_id_simulation fields
This commit is contained in:
parent
65554bcd50
commit
8a0854ceba
|
|
@ -26,6 +26,8 @@ class SimulationStatus(str, Enum):
|
|||
"""Simulation status"""
|
||||
CREATED = "created"
|
||||
PREPARING = "preparing"
|
||||
PROFILES_READY = "profiles_ready" # agents generated, awaiting user confirmation for Fase B
|
||||
CONFIGURING = "configuring" # generating behavior config async
|
||||
READY = "ready"
|
||||
RUNNING = "running"
|
||||
PAUSED = "paused"
|
||||
|
|
@ -75,6 +77,10 @@ class SimulationState:
|
|||
# Error message
|
||||
error: Optional[str] = None
|
||||
|
||||
# F2-A+B fields
|
||||
parent_simulation_id: Optional[str] = None # set when cloned from another simulation
|
||||
graph_id_simulation: Optional[str] = None # per-simulation Neo4j group_id
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Full state dictionary (internal use)"""
|
||||
return {
|
||||
|
|
@ -95,6 +101,8 @@ class SimulationState:
|
|||
"created_at": self.created_at,
|
||||
"updated_at": self.updated_at,
|
||||
"error": self.error,
|
||||
"parent_simulation_id": self.parent_simulation_id,
|
||||
"graph_id_simulation": self.graph_id_simulation,
|
||||
}
|
||||
|
||||
def to_simple_dict(self) -> Dict[str, Any]:
|
||||
|
|
@ -109,6 +117,8 @@ class SimulationState:
|
|||
"entity_types": self.entity_types,
|
||||
"config_generated": self.config_generated,
|
||||
"error": self.error,
|
||||
"parent_simulation_id": self.parent_simulation_id,
|
||||
"graph_id_simulation": self.graph_id_simulation,
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -186,6 +196,8 @@ class SimulationManager:
|
|||
created_at=data.get("created_at", datetime.now().isoformat()),
|
||||
updated_at=data.get("updated_at", datetime.now().isoformat()),
|
||||
error=data.get("error"),
|
||||
parent_simulation_id=data.get("parent_simulation_id"),
|
||||
graph_id_simulation=data.get("graph_id_simulation"),
|
||||
)
|
||||
|
||||
self._simulations[simulation_id] = state
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
import pytest
|
||||
from backend.app.services.simulation_manager import SimulationStatus, SimulationState
|
||||
|
||||
def test_profiles_ready_status_exists():
|
||||
assert SimulationStatus.PROFILES_READY == "profiles_ready"
|
||||
|
||||
def test_configuring_status_exists():
|
||||
assert SimulationStatus.CONFIGURING == "configuring"
|
||||
|
||||
def test_simulation_state_has_parent_id():
|
||||
state = SimulationState(simulation_id="sim_x", project_id="p", graph_id="g")
|
||||
assert hasattr(state, 'parent_simulation_id')
|
||||
assert state.parent_simulation_id is None
|
||||
|
||||
def test_simulation_state_has_graph_id_simulation():
|
||||
state = SimulationState(simulation_id="sim_x", project_id="p", graph_id="g")
|
||||
assert hasattr(state, 'graph_id_simulation')
|
||||
assert state.graph_id_simulation is None
|
||||
|
||||
def test_to_dict_includes_new_fields():
|
||||
state = SimulationState(simulation_id="sim_x", project_id="p", graph_id="g")
|
||||
d = state.to_dict()
|
||||
assert 'parent_simulation_id' in d
|
||||
assert 'graph_id_simulation' in d
|
||||
Loading…
Reference in New Issue