From c848603a904b60ea040e119c983b46633e90a6f2 Mon Sep 17 00:00:00 2001 From: Extroias <91105220+Extroias@users.noreply.github.com> Date: Sat, 12 Sep 2026 00:29:50 -0300 Subject: [PATCH 1/4] feat: initial work --- backend/app/session/engine.py | 67 +++++++++++++++-------------------- backend/app/session/models.py | 20 ++++++----- 2 files changed, 40 insertions(+), 47 deletions(-) diff --git a/backend/app/session/engine.py b/backend/app/session/engine.py index 0333927..6a03fe2 100644 --- a/backend/app/session/engine.py +++ b/backend/app/session/engine.py @@ -222,21 +222,6 @@ def get_question_priority(question: Questions) -> int | None: return priority_map.get(question) - -def get_default_speaker_seconds(state: SessionLiveState) -> int | None: - if state.current_state == States.MODERATED_CAUCUS and state.debate: - return state.debate.per_speaker_seconds - - if state.current_state in { - States.OPEN_GSL, - States.CLOSED_GSL, - States.INITIAL_DEBATE, - }: - return state.gsl_default_time_seconds - - return None - - def reset_timer(state: SessionLiveState, seconds: int = 0) -> None: state.timer_is_running = False state.timer_expiration = None @@ -284,7 +269,6 @@ def handle_delegate_submit_motion( if ( current_state in { - States.MODERATED_CAUCUS, States.UNMODERATED_CAUCUS, } and not state.can_set_motion @@ -359,7 +343,7 @@ def handle_leave_queue( if state.current_state != States.OPEN_GSL: raise EventRejectedError( code=enums.EventErrorCode.INVALID_STATE, - message="Cannot enter queue right now", + message="Cannot leave queue right now", ) if delegate.id not in state.gsl_queue: @@ -431,10 +415,10 @@ def handle_close_session( ) -> DispatchOutcome: require_chair(actor) - if state.current_state != States.ROLL_CALL: + if state.current_state == States.ROLL_CALL: raise EventRejectedError( code=enums.EventErrorCode.INVALID_STATE, - message="Session may only be closed during roll call", + message="Session may not be closed during roll call", #confirm thiss ) state.current_state = States.FINISHED @@ -574,25 +558,28 @@ def apply_passed_motion( next_state = States.MODERATED_CAUCUS state.debate = DebateContext( debate_type=DebateTypes.MODERATED_DEBATE, - return_state=return_state, - per_speaker_seconds=motion.per_speaker_seconds if motion.per_speaker_seconds is not None - else state.gsl_default_time_seconds, + return_state=state.debate, + per_speaker_seconds=motion.per_speaker_seconds if motion.per_speaker_seconds is not None else state.default_time_seconds, total_speeches= motion.speech_count, ) case DebateTypes.UNMODERATED_DEBATE: + duration = motion.total_duration_minutes if motion.total_duration_minutes is not None else 5 next_state = States.UNMODERATED_CAUCUS state.debate = DebateContext( debate_type=DebateTypes.UNMODERATED_DEBATE, - return_state=return_state, + return_state=state.debate, total_duration_seconds=motion.total_duration_minutes, - expires_at=datetime.now(UTC) + timedelta(seconds=motion.total_duration_minutes), ) - reset_timer(state, motion.total_duration_minutes) # Use this as timer + reset_timer(state, motion.total_duration_minutes*60) # Use this as timer case DebateTypes.SPEAKERS_LIST: next_state = States.OPEN_GSL - state.debate = None + state.debate = DebateContext( + debate_type=DebateTypes.SPEAKERS_LIST, + return_state=state.debate, + per_speaker_seconds=state.default_time_seconds, + ) case Motions.POSTPONE_SESSION: pass @@ -624,9 +611,19 @@ def apply_passed_motion( # will define the VotingContext for resolutions pass case Motions.CLOSE_SPEAKERS_LIST: + if state.current_state != States.OPEN_GSL: + raise EventRejectedError( + code=enums.EventErrorCode.INVALID_STATE, + message="Cannot close speakers list if it's not open" + ) next_state = States.CLOSED_GSL case Motions.REOPEN_SPEAKERS_LIST: + if state.current_state != States.CLOSED_GSL: + raise EventRejectedError( + code=enums.EventErrorCode.INVALID_STATE, + message="Cannot reopen speakers list if it's not closed" + ) next_state = States.OPEN_GSL case Motions.SPLIT_PROPOSAL: @@ -703,19 +700,14 @@ def handle_finish_caucus( ) -> DispatchOutcome: require_chair(actor) - if state.debate is None or state.current_state not in { - States.MODERATED_CAUCUS, - States.UNMODERATED_CAUCUS, - }: + if state.debate is None: raise EventRejectedError( code=enums.EventErrorCode.INVALID_STATE, message="No active caucus", ) - return_state = state.debate.return_state + state.debate = state.debate.return_state state.current_speaker = None - state.caucus_list = [] - state.debate = None reset_timer(state) state.current_state = return_state return DispatchOutcome(state=state) @@ -727,7 +719,6 @@ def handle_resolve_motion( ) -> DispatchOutcome: # TODO: check how to resolve INTRODUCE_RESOLUTION_PROPOSAL and INTRODUCE_AMENDMENT_PROPOSAL motions separately from procedural motions require_chair(actor) - payload = event.payload # next() function with generator expression motion = next( @@ -868,7 +859,7 @@ def handle_next_speaker( reset_timer(state) return DispatchOutcome(state=state) state.current_speaker = state.gsl_queue.pop(0) - reset_timer(state, state.gsl_default_time_seconds) + reset_timer(state, state.default_time_seconds) return DispatchOutcome(state=state) if state.current_state == States.TOUR_DE_TABLE: @@ -877,7 +868,7 @@ def handle_next_speaker( reset_timer(state) return DispatchOutcome(state=state) state.current_speaker = state.caucus_list.pop(0) - reset_timer(state, state.gsl_default_time_seconds) + reset_timer(state, state.default_time_seconds) return DispatchOutcome(state=state) if state.current_state == States.MODERATED_CAUCUS: @@ -932,7 +923,7 @@ def handle_grant_floor( if state.current_state in {States.OPEN_GSL, States.CLOSED_GSL}: if representation_id in state.gsl_queue: state.gsl_queue.remove(representation_id) - seconds = event.payload.seconds or state.gsl_default_time_seconds + seconds = event.payload.seconds or state.default_time_seconds elif state.current_state == States.MODERATED_CAUCUS: if state.debate is None: raise EventRejectedError( @@ -944,7 +935,7 @@ def handle_grant_floor( elif state.current_state == States.TOUR_DE_TABLE: if representation_id in state.caucus_list: state.caucus_list.remove(representation_id) - seconds = event.payload.seconds or state.gsl_default_time_seconds + seconds = event.payload.seconds or state.default_time_seconds elif state.current_state == States.UNMODERATED_CAUCUS: raise EventRejectedError( code=enums.EventErrorCode.INVALID_STATE, diff --git a/backend/app/session/models.py b/backend/app/session/models.py index 4626db8..5402cad 100644 --- a/backend/app/session/models.py +++ b/backend/app/session/models.py @@ -5,6 +5,7 @@ from typing import Any from uuid import UUID +from __future__ import annotations from pydantic import BaseModel import app.session.enums as enums @@ -78,14 +79,18 @@ def is_choice_allowed(self, choice: enums.VotingChoice) -> bool: return True - class DebateContext(BaseModel): debate_type: enums.DebateTypes - return_state: enums.States - total_duration_seconds: int | None = None # check if its needed + return_state: DebateContext | None #None only if default state + + #unmoderated debate + total_duration_minutes: int | None = None + #moderated debate total_speeches: int | None = None + #moderated debate and GSL per_speaker_seconds: int | None = None - expires_at: datetime | None = None + #GSL + closed: bool | None = None class RollCallContext(BaseModel): @@ -117,14 +122,11 @@ class SessionLiveState(BaseModel): # Speakers current_speaker: int | None = None - gsl_queue: list[int] = [] + gsl_queue: list[int] = [] #Never resets, so it's in global context can_set_motion: bool = False # Can set motions during speaking time - gsl_default_time_seconds: int = 60 + default_time_seconds: int = 60 # Caucus variables - caucus_list: list[ - int - ] = [] # special list that is only used during moderated caucus, has different semantic functionality than gsl queue debate: DebateContext | None = ( None # used specially for Moderated, unmoderated and possibly tour de table ) From b0cdecd4975d95700c927cc07e60840f7ec1f8a5 Mon Sep 17 00:00:00 2001 From: Extroias <91105220+Extroias@users.noreply.github.com> Date: Mon, 12 Oct 2026 21:11:51 -0300 Subject: [PATCH 2/4] feat: decouples OpenGSL as default state other default states don't work yet, will do refactor first --- backend/app/session/engine.py | 18 ++++++++++++------ backend/app/session/models.py | 8 ++++++-- frontend/src/pages/CreateCommittee.tsx | 4 ++-- frontend/src/schemas/types.gen.ts | 20 +++++++++----------- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/backend/app/session/engine.py b/backend/app/session/engine.py index 6a03fe2..36d199a 100644 --- a/backend/app/session/engine.py +++ b/backend/app/session/engine.py @@ -271,7 +271,7 @@ def handle_delegate_submit_motion( in { States.UNMODERATED_CAUCUS, } - and not state.can_set_motion + and not state.can_set_motion #????? ): raise EventRejectedError( code=enums.EventErrorCode.INVALID_STATE, @@ -558,7 +558,8 @@ def apply_passed_motion( next_state = States.MODERATED_CAUCUS state.debate = DebateContext( debate_type=DebateTypes.MODERATED_DEBATE, - return_state=state.debate, + return_debate=state.debate, + return_state=state.current_state, per_speaker_seconds=motion.per_speaker_seconds if motion.per_speaker_seconds is not None else state.default_time_seconds, total_speeches= motion.speech_count, ) @@ -568,7 +569,8 @@ def apply_passed_motion( next_state = States.UNMODERATED_CAUCUS state.debate = DebateContext( debate_type=DebateTypes.UNMODERATED_DEBATE, - return_state=state.debate, + return_debate=state.debate, + return_state=state.current_state, total_duration_seconds=motion.total_duration_minutes, ) reset_timer(state, motion.total_duration_minutes*60) # Use this as timer @@ -617,6 +619,7 @@ def apply_passed_motion( message="Cannot close speakers list if it's not open" ) next_state = States.CLOSED_GSL + state.debate.closed = True case Motions.REOPEN_SPEAKERS_LIST: if state.current_state != States.CLOSED_GSL: @@ -625,6 +628,7 @@ def apply_passed_motion( message="Cannot reopen speakers list if it's not closed" ) next_state = States.OPEN_GSL + state.debate.closed = False case Motions.SPLIT_PROPOSAL: # note: seems more like an informal consultation @@ -706,10 +710,10 @@ def handle_finish_caucus( message="No active caucus", ) - state.debate = state.debate.return_state + state.debate = state.debate.return_debate state.current_speaker = None reset_timer(state) - state.current_state = return_state + state.current_state = state.debate.return_state return DispatchOutcome(state=state) @@ -1073,7 +1077,9 @@ def handle_close_roll_call( state.roll_call.registry.setdefault(delegation_id, RollCallChoice.ABSENT) # Initial roll call enters Open GSL; quorum roll calls restore their source state. - state.current_state = state.roll_call.return_state or States.OPEN_GSL + state.current_state = state.roll_call.return_state or state.default_debate + if not state.roll_call.return_state: + state.debate = DebateContext(debate_type=enums.DebateTypes.SPEAKERS_LIST) state.roll_call.registry = { delegation_id: RollCallChoice.PRESENT_AND_VOTING if choice == RollCallChoice.PRESENT_AND_VOTING diff --git a/backend/app/session/models.py b/backend/app/session/models.py index 5402cad..8a75bfe 100644 --- a/backend/app/session/models.py +++ b/backend/app/session/models.py @@ -1,11 +1,12 @@ # This file defines internal models not used as schemas for the application # Even though it's internal, some things may be sent out to public (TODO:like SessionLiveState) +from __future__ import annotations from dataclasses import dataclass from datetime import datetime +from sre_parse import State from typing import Any from uuid import UUID -from __future__ import annotations from pydantic import BaseModel import app.session.enums as enums @@ -81,7 +82,8 @@ def is_choice_allowed(self, choice: enums.VotingChoice) -> bool: class DebateContext(BaseModel): debate_type: enums.DebateTypes - return_state: DebateContext | None #None only if default state + return_debate: DebateContext | None = None#None only if default state + return_state: enums.States | None = None #TEMPORARY #unmoderated debate total_duration_minutes: int | None = None @@ -154,6 +156,8 @@ class SessionLiveState(BaseModel): # Additional config has_veto_power: bool = False + #Temporary Config + default_debate: enums.States = enums.States.OPEN_GSL #change this #Add more for other effects (Possibly change the Voting context, when doing that change frontend too) EffectPayloads = VotingContext diff --git a/frontend/src/pages/CreateCommittee.tsx b/frontend/src/pages/CreateCommittee.tsx index ec46086..6777b4a 100644 --- a/frontend/src/pages/CreateCommittee.tsx +++ b/frontend/src/pages/CreateCommittee.tsx @@ -2,7 +2,7 @@ import { Button } from "@/components/ui/button" export default function SessionPage() { const payload = { - session_id: 0, + session_id: 1, name: "CSNU", delegations: [ { seat: "3-4", name: "Albânia", code: "al" }, @@ -40,7 +40,7 @@ export default function SessionPage() { body: JSON.stringify(payload), headers: { "Content-Type": "application/json" }, }) - .then(() => window.location.href = "/committees/0/session") + .then(() => window.location.href = "/committees/1/session") } } diff --git a/frontend/src/schemas/types.gen.ts b/frontend/src/schemas/types.gen.ts index 8a7e8ec..4c457bb 100644 --- a/frontend/src/schemas/types.gen.ts +++ b/frontend/src/schemas/types.gen.ts @@ -1055,11 +1055,12 @@ export type AgendaItem = { */ export type DebateContext = { debate_type: DebateTypes; - return_state: States; + return_debate?: DebateContext | null; + return_state?: States | null; /** - * Total Duration Seconds + * Total Duration Minutes */ - total_duration_seconds?: number | null; + total_duration_minutes?: number | null; /** * Total Speeches */ @@ -1069,9 +1070,9 @@ export type DebateContext = { */ per_speaker_seconds?: number | null; /** - * Expires At + * Closed */ - expires_at?: string | null; + closed?: boolean | null; }; /** @@ -1290,13 +1291,9 @@ export type SessionLiveState = { */ can_set_motion?: boolean; /** - * Gsl Default Time Seconds - */ - gsl_default_time_seconds?: number; - /** - * Caucus List + * Default Time Seconds */ - caucus_list?: Array; + default_time_seconds?: number; debate?: DebateContext | null; /** * Submitted Motions @@ -1326,6 +1323,7 @@ export type SessionLiveState = { * Has Veto Power */ has_veto_power?: boolean; + default_debate?: States; }; /** From 1e5c1e351817e7576db9efbfe701e3af119d4bf2 Mon Sep 17 00:00:00 2001 From: Extroias <91105220+Extroias@users.noreply.github.com> Date: Tue, 13 Oct 2026 00:26:02 -0300 Subject: [PATCH 3/4] feat: start of state machine --- backend/app/session/states.py | 130 ++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 backend/app/session/states.py diff --git a/backend/app/session/states.py b/backend/app/session/states.py new file mode 100644 index 0000000..0ed2aa7 --- /dev/null +++ b/backend/app/session/states.py @@ -0,0 +1,130 @@ +from models import SessionLiveState +import enums + +class SessionState: + + def enterState(self, state : SessionLiveState): + ... + + def exitState(self, state: SessionLiveState): + ... + +class SetupState(SessionState): + state_name = enums.States.SETUP + + def __init__(self): + ... + + def enterState(self, state: SessionLiveState): + ... + + def exitState(self, state: SessionLiveState): + ... + +class RollCallState(SessionState): + state_name = enums.States.ROLL_CALL + + def __init__(self): + ... + + def enterState(self, state: SessionLiveState): + ... + + def exitState(self, state: SessionLiveState): + ... + +class OpenGSLState(SessionState): + state_name = enums.States.OPEN_GSL + + def __init__(self): + ... + + def enterState(self, state: SessionLiveState): + ... + + def exitState(self, state: SessionLiveState): + ... + +class ClosedGSLState(SessionState): + state_name = enums.States.CLOSED_GSL + + def __init__(self): + ... + def enterState(self, state: SessionLiveState): + ... + + def exitState(self, state: SessionLiveState): + ... + +class ModeratedCaucusState(SessionState): + state_name = enums.States.MODERATED_CAUCUS + + def __init__(self): + ... + + def enterState(self, state: SessionLiveState): + ... + + def exitState(self, state: SessionLiveState): + ... + +class UnmoderatedCaucusState(SessionState): + state_name = enums.States.UNMODERATED_CAUCUS + + def __init__(self): + ... + + def enterState(self, state: SessionLiveState): + ... + + def exitState(self, state: SessionLiveState): + ... + +class TourDeTableState(SessionState): + state_name = enums.States.TOUR_DE_TABLE + + def __init__(self): + ... + + def enterState(self, state: SessionLiveState): + ... + + def exitState(self, state: SessionLiveState): + ... + + +class VotingExecution(SessionState): + state_name = enums.States.VOTING_EXECUTION + + def __init__(self): + ... + + def enterState(self, state: SessionLiveState): + ... + + def exitState(self, state: SessionLiveState): + ... + +class FinishedState(SessionState): + state_name = enums.States.VOTING_EXECUTION + def __init__(self): + ... + + def enterState(self, state: SessionLiveState): + ... + + def exitState(self, state: SessionLiveState): + ... + +class SessionStateMachine: + + current_state : SessionState + + def __init__(self, context: SessionLiveState): + self.current_state = SetupState() + self.current_state.enterState(context) + + def transition_to(self, context: SessionLiveState, state: SessionState): + self.current_state.exitState(context) + self.current_state = state + self.current_state.enterState(context) \ No newline at end of file From c4bc494da7e3e18b55441f929d36198082b7d14d Mon Sep 17 00:00:00 2001 From: Extroias <91105220+Extroias@users.noreply.github.com> Date: Sat, 17 Oct 2026 00:20:39 -0300 Subject: [PATCH 4/4] refactor: now we have a proper state machine --- backend/app/session/engine.py | 147 +++++-------- backend/app/session/models.py | 186 ++++++++++++++-- backend/app/session/service.py | 17 +- backend/app/session/states.py | 130 ------------ frontend/src/schemas/types.gen.ts | 338 +++++++++++++++++++++++++++++- 5 files changed, 564 insertions(+), 254 deletions(-) delete mode 100644 backend/app/session/states.py diff --git a/backend/app/session/engine.py b/backend/app/session/engine.py index 36d199a..f17aa6b 100644 --- a/backend/app/session/engine.py +++ b/backend/app/session/engine.py @@ -18,16 +18,23 @@ ) from .models import ( AgendaItem, - DebateContext, + ClosedGSLState, DelegationContext, DispatchOutcome, MotionContext, + OpenGSLState, QuestionContext, - RollCallContext, SessionActor, SessionEffect, SessionLiveState, + StateTypes, + TourDeTableState, VotingContext, + ModeratedCaucusState, + UnmoderatedCaucusState, + RollCallState, + VotingExecutionState, + FinishedState, ) @@ -398,8 +405,7 @@ def handle_open_session( message="Cannot open session out of setup", ) - state.current_state = States.ROLL_CALL - state.roll_call = RollCallContext(registry={}) + state.transition_to(RollCallState()) state.gsl_queue = [] state.current_speaker = None state.debate = None @@ -421,16 +427,7 @@ def handle_close_session( message="Session may not be closed during roll call", #confirm thiss ) - state.current_state = States.FINISHED - state.current_speaker = None - state.gsl_queue = [] # I'm supposing this queue has the first element popped when someone speaks, - # so it should be empty when session is closed. In case this list is to be kept, - # we can remove this line. - state.can_set_motion = False - state.debate = None # Same as queue - state.timer_is_running = False - state.timer_expiration = None - state.timer_remaining_seconds = 0 + state.transition_to(FinishedState()) return DispatchOutcome(state=state) @@ -493,14 +490,12 @@ def handle_open_informal_voting( message="Cannot open voting with voting in course", ) - state.voting = VotingContext( + state.transition_to(VotingExecutionState(context = VotingContext( target_type=enums.VotingType.INFORMAL, title=event.payload.title, - return_state=state.current_state, + return_state=state.state_obj, voting_registry={}, - ) - - state.current_state = States.VOTING_EXECUTION + ))) return DispatchOutcome(state=state) @@ -527,19 +522,15 @@ def handle_close_informal_voting( message="Cannot close voting", ) - # extract last state - state.current_state = state.voting.return_state - - state.voting = None + state.transition_to(state.voting.return_state) return DispatchOutcome(state=state) def apply_passed_motion( - state: SessionLiveState, motion: MotionContext, return_state: States + state: SessionLiveState, motion: MotionContext, return_state: StateTypes ) -> None: """Apply a passed procedural motion to the live session state in place.""" - next_state = return_state # as fallback state.current_speaker = None state.timer_is_running = False state.timer_expiration = None @@ -555,55 +546,32 @@ def apply_passed_motion( match motion.debate_type: case DebateTypes.MODERATED_DEBATE: - next_state = States.MODERATED_CAUCUS - state.debate = DebateContext( - debate_type=DebateTypes.MODERATED_DEBATE, - return_debate=state.debate, - return_state=state.current_state, - per_speaker_seconds=motion.per_speaker_seconds if motion.per_speaker_seconds is not None else state.default_time_seconds, - total_speeches= motion.speech_count, - ) + state.transition_to(ModeratedCaucusState( + return_state=return_state, + per_speaker_seconds=motion.per_speaker_seconds, + total_speeches=motion.speech_count)) case DebateTypes.UNMODERATED_DEBATE: - duration = motion.total_duration_minutes if motion.total_duration_minutes is not None else 5 - next_state = States.UNMODERATED_CAUCUS - state.debate = DebateContext( - debate_type=DebateTypes.UNMODERATED_DEBATE, - return_debate=state.debate, - return_state=state.current_state, - total_duration_seconds=motion.total_duration_minutes, - ) - reset_timer(state, motion.total_duration_minutes*60) # Use this as timer + state.transition_to(UnmoderatedCaucusState( + return_state=return_state, + total_duration_minutes=motion.total_duration_minutes)) case DebateTypes.SPEAKERS_LIST: - next_state = States.OPEN_GSL - state.debate = DebateContext( - debate_type=DebateTypes.SPEAKERS_LIST, - return_state=state.debate, - per_speaker_seconds=state.default_time_seconds, - ) + state.transition_to(OpenGSLState(return_state=return_state, + per_speaker_seconds=state.default_time_seconds)) case Motions.POSTPONE_SESSION: pass case Motions.REOPEN_SESSION: pass case Motions.TOUR_DE_TABLE: - next_state = States.TOUR_DE_TABLE - state.caucus_list = [ - del_id - for del_id, choice in state.roll_call.registry.items() - if choice - in ( - enums.RollCallChoice.PRESENT, - enums.RollCallChoice.PRESENT_AND_VOTING, - ) - ] + state.transition_to(TourDeTableState()) case Motions.END_DEBATE: # clean gsl list state.gsl_queue = [] state.debate = None - reset_timer(state) + state.reset_timer() next_state = States.VOTING_PROCEDURES # or VOTING_PREPARATION case Motions.VOTE_AMENDMENT: @@ -618,8 +586,8 @@ def apply_passed_motion( code=enums.EventErrorCode.INVALID_STATE, message="Cannot close speakers list if it's not open" ) - next_state = States.CLOSED_GSL - state.debate.closed = True + state.transition_to(ClosedGSLState(return_state=return_state, + per_speaker_seconds=state.state_obj.per_speaker_seconds)) case Motions.REOPEN_SPEAKERS_LIST: if state.current_state != States.CLOSED_GSL: @@ -627,8 +595,8 @@ def apply_passed_motion( code=enums.EventErrorCode.INVALID_STATE, message="Cannot reopen speakers list if it's not closed" ) - next_state = States.OPEN_GSL - state.debate.closed = False + state.transition_to(OpenGSLState(return_state=return_state, + per_speaker_seconds=state.state_obj.per_speaker_seconds)) case Motions.SPLIT_PROPOSAL: # note: seems more like an informal consultation @@ -637,17 +605,13 @@ def apply_passed_motion( # note: seems more like an informal consultation pass case Motions.QUORUM: - state.roll_call = RollCallContext(registry={}, return_state=return_state) - next_state = States.ROLL_CALL + state.transition_to(RollCallState(return_state=return_state)) case _: raise EventRejectedError( code=enums.EventErrorCode.INVALID_MESSAGE, message="Undefined motion type", ) - # additional case: if we went from GSL to something, save gsl structures - state.current_state = next_state - def handle_close_procedural_voting( state: SessionLiveState, @@ -692,10 +656,8 @@ def handle_close_procedural_voting( apply_passed_motion(state, motion, return_state=state.voting.return_state) else: # motion failed, so return to last state - state.current_state = state.voting.return_state + state.transition_to(state.voting.return_state) - # clear state voting - state.voting = None return DispatchOutcome(state=state, effect=effect) @@ -710,10 +672,15 @@ def handle_finish_caucus( message="No active caucus", ) - state.debate = state.debate.return_debate + if state.debate.return_state is None: + raise EventRejectedError( + code=enums.EventErrorCode.INVALID_STATE, + message="No state to return to", + ) + + state.transition_to(state.debate.return_state) state.current_speaker = None - reset_timer(state) - state.current_state = state.debate.return_state + state.reset_timer() return DispatchOutcome(state=state) @@ -742,15 +709,12 @@ def handle_resolve_motion( ) if payload.action: - state.voting = VotingContext( + state.transition_to(VotingExecutionState(context=VotingContext( target_type=enums.VotingType.PROCEDURAL, motion_in_vote=motion, - return_state=state.current_state, - voting_registry={}, + return_state=state.state_obj, majority=majority_type, - ) - - state.current_state = States.VOTING_EXECUTION + ))) state.submitted_motions.remove(motion) @@ -787,15 +751,14 @@ def handle_chair_submit_motion( ) # set state to be in voting execution - state.voting = VotingContext( + state.transition_to(VotingExecutionState(context=VotingContext( target_type=enums.VotingType.PROCEDURAL, motion_in_vote=context, - return_state=state.current_state, + return_state=state.state_obj, voting_registry={}, majority=majority_type, - ) + ))) - state.current_state = States.VOTING_EXECUTION return DispatchOutcome(state=state) def handle_clear_motions( @@ -860,19 +823,19 @@ def handle_next_speaker( if state.current_state in {States.OPEN_GSL, States.CLOSED_GSL}: if not state.gsl_queue: state.current_speaker = None - reset_timer(state) + state.reset_timer() return DispatchOutcome(state=state) state.current_speaker = state.gsl_queue.pop(0) - reset_timer(state, state.default_time_seconds) + state.reset_timer(state.default_time_seconds) return DispatchOutcome(state=state) if state.current_state == States.TOUR_DE_TABLE: if not state.caucus_list: state.current_speaker = None - reset_timer(state) + state.reset_timer() return DispatchOutcome(state=state) state.current_speaker = state.caucus_list.pop(0) - reset_timer(state, state.default_time_seconds) + state.reset_timer(state.default_time_seconds) return DispatchOutcome(state=state) if state.current_state == States.MODERATED_CAUCUS: @@ -952,7 +915,7 @@ def handle_grant_floor( ) state.current_speaker = representation_id - reset_timer(state, seconds) + state.reset_timer(seconds) return DispatchOutcome(state=state) @@ -1023,7 +986,7 @@ def handle_end_speech( state.previous_speakers.append(state.current_speaker) state.current_speaker = None - reset_timer(state) + state.reset_timer() return DispatchOutcome(state=state) @@ -1077,9 +1040,7 @@ def handle_close_roll_call( state.roll_call.registry.setdefault(delegation_id, RollCallChoice.ABSENT) # Initial roll call enters Open GSL; quorum roll calls restore their source state. - state.current_state = state.roll_call.return_state or state.default_debate - if not state.roll_call.return_state: - state.debate = DebateContext(debate_type=enums.DebateTypes.SPEAKERS_LIST) + state.transition_to(state.roll_call.return_state or state.default_debate) state.roll_call.registry = { delegation_id: RollCallChoice.PRESENT_AND_VOTING if choice == RollCallChoice.PRESENT_AND_VOTING diff --git a/backend/app/session/models.py b/backend/app/session/models.py index 8a75bfe..794d7a9 100644 --- a/backend/app/session/models.py +++ b/backend/app/session/models.py @@ -2,14 +2,17 @@ # Even though it's internal, some things may be sent out to public (TODO:like SessionLiveState) from __future__ import annotations from dataclasses import dataclass +from abc import ABC, abstractmethod from datetime import datetime from sre_parse import State -from typing import Any +from token import OP +from typing import Any, Literal, Annotated, ClassVar from uuid import UUID -from pydantic import BaseModel +from pydantic import BaseModel, Field import app.session.enums as enums +from app.session.enums import States @dataclass(frozen=True) @@ -65,7 +68,7 @@ class QuestionContext(BaseModel): class VotingContext(BaseModel): target_type: enums.VotingType title: str | None = None - return_state: enums.States + return_state: StateTypes voting_registry: dict[int, enums.VotingChoice] = {} majority: enums.MajorityTypes | None = None @@ -82,11 +85,10 @@ def is_choice_allowed(self, choice: enums.VotingChoice) -> bool: class DebateContext(BaseModel): debate_type: enums.DebateTypes - return_debate: DebateContext | None = None#None only if default state - return_state: enums.States | None = None #TEMPORARY + return_state: StateTypes | None = None #TEMPORARY #unmoderated debate - total_duration_minutes: int | None = None + total_duration_seconds: int | None = None #moderated debate total_speeches: int | None = None #moderated debate and GSL @@ -97,7 +99,7 @@ class DebateContext(BaseModel): class RollCallContext(BaseModel): registry: dict[int, enums.RollCallChoice] = {} # Delegation Id as key - return_state: enums.States | None = None + return_state: StateTypes | None = None class AgendaItem(BaseModel): @@ -105,6 +107,153 @@ class AgendaItem(BaseModel): topic: str already_discussed: bool +##SESSION STATES + +class SessionState(BaseModel, ABC): + + state_name : ClassVar + + @abstractmethod + def enterState(self, state : SessionLiveState): + ... + + @abstractmethod + def exitState(self, state: SessionLiveState): + ... + +class SetupState(SessionState): + """Dummy starting State, it's properties are defined when activating a session""" + state_name : Literal[States.SETUP] = States.SETUP + + def enterState(self, state: SessionLiveState): + ... + + def exitState(self, state: SessionLiveState): + ... + +class RollCallState(SessionState): + state_name : Literal[States.ROLL_CALL] = States.ROLL_CALL + return_state : StateTypes | None = None + + def enterState(self, state: SessionLiveState): + state.roll_call = RollCallContext(registry={}, return_state=self.return_state) + + def exitState(self, state: SessionLiveState): + ... + +class OpenGSLState(SessionState): + state_name : Literal[States.OPEN_GSL] = States.OPEN_GSL + return_state : StateTypes | None = None + per_speaker_seconds : int | None = None + + def enterState(self, state: SessionLiveState): + state.debate = DebateContext( + debate_type=enums.DebateTypes.SPEAKERS_LIST, + return_state=self.return_state, + per_speaker_seconds=self.per_speaker_seconds or state.default_time_seconds, + closed=False + ) + + def exitState(self, state: SessionLiveState): + state.debate = None + +class ClosedGSLState(SessionState): + state_name : Literal[States.CLOSED_GSL] = States.CLOSED_GSL + return_state : StateTypes | None = None + per_speaker_seconds : int | None = None + + def enterState(self, state: SessionLiveState): + state.debate = DebateContext( + debate_type=enums.DebateTypes.SPEAKERS_LIST, + return_state=self.return_state, + per_speaker_seconds=self.per_speaker_seconds or state.default_time_seconds, + closed=True + ) + + def exitState(self, state: SessionLiveState): + state.debate = None + +class ModeratedCaucusState(SessionState): + state_name : Literal[States.MODERATED_CAUCUS] = States.MODERATED_CAUCUS + return_state : StateTypes | None = None + per_speaker_seconds : int | None = None + total_speeches : int | None = None + + def enterState(self, state: SessionLiveState): + state.debate = DebateContext( + debate_type=enums.DebateTypes.MODERATED_DEBATE, + return_state=self.return_state, + per_speaker_seconds=self.per_speaker_seconds or state.default_time_seconds, + total_speeches= self.total_speeches, + ) + + def exitState(self, state: SessionLiveState): + state.debate = None + +class UnmoderatedCaucusState(SessionState): + state_name : Literal[States.UNMODERATED_CAUCUS] = States.UNMODERATED_CAUCUS + return_state : StateTypes | None = None + total_duration_minutes : int | None + + def enterState(self, state: SessionLiveState): + duration = (self.total_duration_minutes or 5) * 60 + state.debate = DebateContext( + debate_type=enums.DebateTypes.UNMODERATED_DEBATE, + return_state=self.return_state, + total_duration_seconds=duration, + ) + state.reset_timer(duration) + + def exitState(self, state: SessionLiveState): + state.debate = None + +class TourDeTableState(SessionState): + """To be implemented""" + state_name : Literal[States.TOUR_DE_TABLE] = States.TOUR_DE_TABLE + + def enterState(self, state: SessionLiveState): + ... + + def exitState(self, state: SessionLiveState): + state.debate = None + + +class VotingExecutionState(SessionState): + state_name : Literal[States.VOTING_EXECUTION] = States.VOTING_EXECUTION + + context : VotingContext + def enterState(self, state: SessionLiveState): + state.voting = self.context + def exitState(self, state: SessionLiveState): + state.voting = None + +class FinishedState(SessionState): + state_name : Literal[States.FINISHED] = States.FINISHED + + def enterState(self, state: SessionLiveState): + state.current_speaker = None + state.gsl_queue = [] # I'm supposing this queue has the first element popped when someone speaks, + # so it should be empty when session is closed. In case this list is to be kept, + # we can remove this line. + state.can_set_motion = False + state.debate = None # Same as queue + state.timer_is_running = False + state.timer_expiration = None + state.timer_remaining_seconds = 0 + + def exitState(self, state: SessionLiveState): + ... + +StateTypes = Annotated[ + SetupState | + RollCallState | + OpenGSLState | + ClosedGSLState | + ModeratedCaucusState | + UnmoderatedCaucusState | + TourDeTableState | + VotingExecutionState | + FinishedState, Field(discriminator="state_name") ] # Represents the session live state class SessionLiveState(BaseModel): @@ -114,6 +263,8 @@ class SessionLiveState(BaseModel): # list of present representations (rep_id) delegations: dict[int, DelegationContext] + #private state object for FSM engine + state_obj : StateTypes # General state for FSM engine current_state: enums.States = enums.States.SETUP @@ -148,7 +299,7 @@ class SessionLiveState(BaseModel): voting: VotingContext | None = None # present delegations with voting choice - roll_call: RollCallContext # Not None, even if registry is empty + roll_call: RollCallContext = RollCallContext() # Not None, even if registry is empty #Temporary Speaker History previous_speakers: list[int] = [] #temporary list for now @@ -156,15 +307,26 @@ class SessionLiveState(BaseModel): # Additional config has_veto_power: bool = False - #Temporary Config - default_debate: enums.States = enums.States.OPEN_GSL #change this + default_debate: OpenGSLState | ModeratedCaucusState | UnmoderatedCaucusState = Field(discriminator="state_name") + + def transition_to(self: SessionLiveState, state: StateTypes) -> None: + self.state_obj.exitState(self) + state.enterState(self) + self.current_state = state.state_name + self.state_obj = state + + def reset_timer(self: SessionLiveState, seconds: int = 0) -> None: + self.timer_is_running = False + self.timer_expiration = None + self.timer_remaining_seconds = seconds + #Add more for other effects (Possibly change the Voting context, when doing that change frontend too) -EffectPayloads = VotingContext +EffectPayloads = VotingContext | None class SessionEffect(BaseModel): type: enums.SessionEffectType - data: EffectPayloads = {} + data: EffectPayloads = None class DispatchOutcome(BaseModel): diff --git a/backend/app/session/service.py b/backend/app/session/service.py index cda8ada..007c356 100644 --- a/backend/app/session/service.py +++ b/backend/app/session/service.py @@ -27,9 +27,10 @@ from .models import ( DelegationContext, DispatchOutcome, - RollCallContext, SessionActor, SessionLiveState, + SetupState, + OpenGSLState ) @@ -126,14 +127,12 @@ async def activate_session( if delegations is None: raise ConflictError("Session delegations are unavailable") - live_state = SessionLiveState( - session_id=stored.id, - start_time=datetime.now(), - delegations=delegations, - current_state=enums.States.SETUP, - gsl_default_time_seconds=60, - roll_call=RollCallContext(registry={}), - ) + live_state = SessionLiveState(session_id=stored.id, + start_time=datetime.now(), + delegations=delegations, + default_debate = OpenGSLState(), + state_obj=SetupState()) + live_state.transition_to(SetupState()) updated = replace( stored, diff --git a/backend/app/session/states.py b/backend/app/session/states.py deleted file mode 100644 index 0ed2aa7..0000000 --- a/backend/app/session/states.py +++ /dev/null @@ -1,130 +0,0 @@ -from models import SessionLiveState -import enums - -class SessionState: - - def enterState(self, state : SessionLiveState): - ... - - def exitState(self, state: SessionLiveState): - ... - -class SetupState(SessionState): - state_name = enums.States.SETUP - - def __init__(self): - ... - - def enterState(self, state: SessionLiveState): - ... - - def exitState(self, state: SessionLiveState): - ... - -class RollCallState(SessionState): - state_name = enums.States.ROLL_CALL - - def __init__(self): - ... - - def enterState(self, state: SessionLiveState): - ... - - def exitState(self, state: SessionLiveState): - ... - -class OpenGSLState(SessionState): - state_name = enums.States.OPEN_GSL - - def __init__(self): - ... - - def enterState(self, state: SessionLiveState): - ... - - def exitState(self, state: SessionLiveState): - ... - -class ClosedGSLState(SessionState): - state_name = enums.States.CLOSED_GSL - - def __init__(self): - ... - def enterState(self, state: SessionLiveState): - ... - - def exitState(self, state: SessionLiveState): - ... - -class ModeratedCaucusState(SessionState): - state_name = enums.States.MODERATED_CAUCUS - - def __init__(self): - ... - - def enterState(self, state: SessionLiveState): - ... - - def exitState(self, state: SessionLiveState): - ... - -class UnmoderatedCaucusState(SessionState): - state_name = enums.States.UNMODERATED_CAUCUS - - def __init__(self): - ... - - def enterState(self, state: SessionLiveState): - ... - - def exitState(self, state: SessionLiveState): - ... - -class TourDeTableState(SessionState): - state_name = enums.States.TOUR_DE_TABLE - - def __init__(self): - ... - - def enterState(self, state: SessionLiveState): - ... - - def exitState(self, state: SessionLiveState): - ... - - -class VotingExecution(SessionState): - state_name = enums.States.VOTING_EXECUTION - - def __init__(self): - ... - - def enterState(self, state: SessionLiveState): - ... - - def exitState(self, state: SessionLiveState): - ... - -class FinishedState(SessionState): - state_name = enums.States.VOTING_EXECUTION - def __init__(self): - ... - - def enterState(self, state: SessionLiveState): - ... - - def exitState(self, state: SessionLiveState): - ... - -class SessionStateMachine: - - current_state : SessionState - - def __init__(self, context: SessionLiveState): - self.current_state = SetupState() - self.current_state.enterState(context) - - def transition_to(self, context: SessionLiveState, state: SessionState): - self.current_state.exitState(context) - self.current_state = state - self.current_state.enterState(context) \ No newline at end of file diff --git a/frontend/src/schemas/types.gen.ts b/frontend/src/schemas/types.gen.ts index 4c457bb..ce2717e 100644 --- a/frontend/src/schemas/types.gen.ts +++ b/frontend/src/schemas/types.gen.ts @@ -1050,17 +1050,73 @@ export type AgendaItem = { already_discussed: boolean; }; +/** + * ClosedGSLState + */ +export type ClosedGslState = { + /** + * State Name + */ + state_name?: 'Closed GSL'; + /** + * Return State + */ + return_state?: ({ + state_name: 'Setup Room'; + } & SetupState) | ({ + state_name: 'Roll Call'; + } & RollCallState) | ({ + state_name: 'Open GSL'; + } & OpenGslState) | ({ + state_name: 'Closed GSL'; + } & ClosedGslState) | ({ + state_name: 'Moderated Caucus'; + } & ModeratedCaucusState) | ({ + state_name: 'Unmoderated Caucus'; + } & UnmoderatedCaucusState) | ({ + state_name: 'Tour de Table'; + } & TourDeTableState) | ({ + state_name: 'Voting Execution'; + } & VotingExecutionState) | ({ + state_name: 'Finished'; + } & FinishedState) | null; + /** + * Per Speaker Seconds + */ + per_speaker_seconds?: number | null; +}; + /** * DebateContext */ export type DebateContext = { debate_type: DebateTypes; - return_debate?: DebateContext | null; - return_state?: States | null; /** - * Total Duration Minutes - */ - total_duration_minutes?: number | null; + * Return State + */ + return_state?: ({ + state_name: 'Setup Room'; + } & SetupState) | ({ + state_name: 'Roll Call'; + } & RollCallState) | ({ + state_name: 'Open GSL'; + } & OpenGslState) | ({ + state_name: 'Closed GSL'; + } & ClosedGslState) | ({ + state_name: 'Moderated Caucus'; + } & ModeratedCaucusState) | ({ + state_name: 'Unmoderated Caucus'; + } & UnmoderatedCaucusState) | ({ + state_name: 'Tour de Table'; + } & TourDeTableState) | ({ + state_name: 'Voting Execution'; + } & VotingExecutionState) | ({ + state_name: 'Finished'; + } & FinishedState) | null; + /** + * Total Duration Seconds + */ + total_duration_seconds?: number | null; /** * Total Speeches */ @@ -1149,6 +1205,56 @@ export type EventRejectedMessage = { message: string; }; +/** + * FinishedState + */ +export type FinishedState = { + /** + * State Name + */ + state_name?: 'Finished'; +}; + +/** + * ModeratedCaucusState + */ +export type ModeratedCaucusState = { + /** + * State Name + */ + state_name?: 'Moderated Caucus'; + /** + * Return State + */ + return_state?: ({ + state_name: 'Setup Room'; + } & SetupState) | ({ + state_name: 'Roll Call'; + } & RollCallState) | ({ + state_name: 'Open GSL'; + } & OpenGslState) | ({ + state_name: 'Closed GSL'; + } & ClosedGslState) | ({ + state_name: 'Moderated Caucus'; + } & ModeratedCaucusState) | ({ + state_name: 'Unmoderated Caucus'; + } & UnmoderatedCaucusState) | ({ + state_name: 'Tour de Table'; + } & TourDeTableState) | ({ + state_name: 'Voting Execution'; + } & VotingExecutionState) | ({ + state_name: 'Finished'; + } & FinishedState) | null; + /** + * Per Speaker Seconds + */ + per_speaker_seconds?: number | null; + /** + * Total Speeches + */ + total_speeches?: number | null; +}; + /** * MotionContext */ @@ -1193,6 +1299,42 @@ export type MotionContext = { details?: string | null; }; +/** + * OpenGSLState + */ +export type OpenGslState = { + /** + * State Name + */ + state_name?: 'Open GSL'; + /** + * Return State + */ + return_state?: ({ + state_name: 'Setup Room'; + } & SetupState) | ({ + state_name: 'Roll Call'; + } & RollCallState) | ({ + state_name: 'Open GSL'; + } & OpenGslState) | ({ + state_name: 'Closed GSL'; + } & ClosedGslState) | ({ + state_name: 'Moderated Caucus'; + } & ModeratedCaucusState) | ({ + state_name: 'Unmoderated Caucus'; + } & UnmoderatedCaucusState) | ({ + state_name: 'Tour de Table'; + } & TourDeTableState) | ({ + state_name: 'Voting Execution'; + } & VotingExecutionState) | ({ + state_name: 'Finished'; + } & FinishedState) | null; + /** + * Per Speaker Seconds + */ + per_speaker_seconds?: number | null; +}; + /** * QuestionContext */ @@ -1226,7 +1368,60 @@ export type RollCallContext = { registry?: { [key: string]: RollCallChoice; }; - return_state?: States | null; + /** + * Return State + */ + return_state?: ({ + state_name: 'Setup Room'; + } & SetupState) | ({ + state_name: 'Roll Call'; + } & RollCallState) | ({ + state_name: 'Open GSL'; + } & OpenGslState) | ({ + state_name: 'Closed GSL'; + } & ClosedGslState) | ({ + state_name: 'Moderated Caucus'; + } & ModeratedCaucusState) | ({ + state_name: 'Unmoderated Caucus'; + } & UnmoderatedCaucusState) | ({ + state_name: 'Tour de Table'; + } & TourDeTableState) | ({ + state_name: 'Voting Execution'; + } & VotingExecutionState) | ({ + state_name: 'Finished'; + } & FinishedState) | null; +}; + +/** + * RollCallState + */ +export type RollCallState = { + /** + * State Name + */ + state_name?: 'Roll Call'; + /** + * Return State + */ + return_state?: ({ + state_name: 'Setup Room'; + } & SetupState) | ({ + state_name: 'Roll Call'; + } & RollCallState) | ({ + state_name: 'Open GSL'; + } & OpenGslState) | ({ + state_name: 'Closed GSL'; + } & ClosedGslState) | ({ + state_name: 'Moderated Caucus'; + } & ModeratedCaucusState) | ({ + state_name: 'Unmoderated Caucus'; + } & UnmoderatedCaucusState) | ({ + state_name: 'Tour de Table'; + } & TourDeTableState) | ({ + state_name: 'Voting Execution'; + } & VotingExecutionState) | ({ + state_name: 'Finished'; + } & FinishedState) | null; }; /** @@ -1234,7 +1429,7 @@ export type RollCallContext = { */ export type SessionEffect = { type: SessionEffectType; - data?: VotingContext; + data?: VotingContext | null; }; /** @@ -1265,6 +1460,28 @@ export type SessionLiveState = { delegations: { [key: string]: DelegationContext; }; + /** + * State Obj + */ + state_obj: ({ + state_name: 'Setup Room'; + } & SetupState) | ({ + state_name: 'Roll Call'; + } & RollCallState) | ({ + state_name: 'Open GSL'; + } & OpenGslState) | ({ + state_name: 'Closed GSL'; + } & ClosedGslState) | ({ + state_name: 'Moderated Caucus'; + } & ModeratedCaucusState) | ({ + state_name: 'Unmoderated Caucus'; + } & UnmoderatedCaucusState) | ({ + state_name: 'Tour de Table'; + } & TourDeTableState) | ({ + state_name: 'Voting Execution'; + } & VotingExecutionState) | ({ + state_name: 'Finished'; + } & FinishedState); current_state?: States; /** * Timer Is Running @@ -1314,7 +1531,7 @@ export type SessionLiveState = { */ active_topic_index?: string | null; voting?: VotingContext | null; - roll_call: RollCallContext; + roll_call?: RollCallContext; /** * Previous Speakers */ @@ -1323,7 +1540,28 @@ export type SessionLiveState = { * Has Veto Power */ has_veto_power?: boolean; - default_debate?: States; + /** + * Default Debate + */ + default_debate: ({ + state_name: 'Open GSL'; + } & OpenGslState) | ({ + state_name: 'Moderated Caucus'; + } & ModeratedCaucusState) | ({ + state_name: 'Unmoderated Caucus'; + } & UnmoderatedCaucusState); +}; + +/** + * SetupState + * + * Dummy starting State, it's properties are defined when activating a session + */ +export type SetupState = { + /** + * State Name + */ + state_name?: 'Setup Room'; }; /** @@ -1337,6 +1575,54 @@ export type StateSnapshotMessage = { state: SessionLiveState; }; +/** + * TourDeTableState + * + * To be implemented + */ +export type TourDeTableState = { + /** + * State Name + */ + state_name?: 'Tour de Table'; +}; + +/** + * UnmoderatedCaucusState + */ +export type UnmoderatedCaucusState = { + /** + * State Name + */ + state_name?: 'Unmoderated Caucus'; + /** + * Return State + */ + return_state?: ({ + state_name: 'Setup Room'; + } & SetupState) | ({ + state_name: 'Roll Call'; + } & RollCallState) | ({ + state_name: 'Open GSL'; + } & OpenGslState) | ({ + state_name: 'Closed GSL'; + } & ClosedGslState) | ({ + state_name: 'Moderated Caucus'; + } & ModeratedCaucusState) | ({ + state_name: 'Unmoderated Caucus'; + } & UnmoderatedCaucusState) | ({ + state_name: 'Tour de Table'; + } & TourDeTableState) | ({ + state_name: 'Voting Execution'; + } & VotingExecutionState) | ({ + state_name: 'Finished'; + } & FinishedState) | null; + /** + * Total Duration Minutes + */ + total_duration_minutes: number | null; +}; + /** * VotingContext */ @@ -1346,7 +1632,28 @@ export type VotingContext = { * Title */ title?: string | null; - return_state: States; + /** + * Return State + */ + return_state: ({ + state_name: 'Setup Room'; + } & SetupState) | ({ + state_name: 'Roll Call'; + } & RollCallState) | ({ + state_name: 'Open GSL'; + } & OpenGslState) | ({ + state_name: 'Closed GSL'; + } & ClosedGslState) | ({ + state_name: 'Moderated Caucus'; + } & ModeratedCaucusState) | ({ + state_name: 'Unmoderated Caucus'; + } & UnmoderatedCaucusState) | ({ + state_name: 'Tour de Table'; + } & TourDeTableState) | ({ + state_name: 'Voting Execution'; + } & VotingExecutionState) | ({ + state_name: 'Finished'; + } & FinishedState); /** * Voting Registry */ @@ -1361,6 +1668,17 @@ export type VotingContext = { allow_veto_power?: boolean; }; +/** + * VotingExecutionState + */ +export type VotingExecutionState = { + /** + * State Name + */ + state_name?: 'Voting Execution'; + context: VotingContext; +}; + /** * VotingType */