src.core.project_context_manager module#

Project Context Manager for Marcus Multi-Project Support.

Manages project switching, state isolation, and kanban client lifecycle for multiple concurrent projects.

class src.core.project_context_manager.ProjectContext[source]#

Bases: object

Container for project-specific state and services.

__init__(project_id)[source]#
Parameters:

project_id (str)

class src.core.project_context_manager.ProjectContextManager[source]#

Bases: object

Manages multiple project contexts with state isolation.

Handles: - Project switching - Kanban client lifecycle - State isolation per project - Resource cleanup for inactive projects

MAX_CACHED_PROJECTS = 10#
IDLE_TIMEOUT_MINUTES = 30#
__init__(registry=None, global_context=None)[source]#

Initialize the project context manager.

Parameters:
property lock: Lock#

Get context lock for the current event loop.

set_global_context(context)[source]#

Set the global context to sync project_id with.

Parameters:

context (Context) – The global context instance to update when projects switch.

Return type:

None

async initialize(auto_switch=True)[source]#

Initialize the context manager.

Parameters:

auto_switch (bool) – If True, automatically switch to the active project. Set to False if you want to sync projects before switching.

Return type:

None

async shutdown()[source]#

Shutdown the context manager and cleanup resources.

Return type:

None

async switch_project(project_id)[source]#

Switch to a different project.

Parameters:

project_id (str) – Target project ID.

Returns:

True if successful.

Return type:

bool

async get_kanban_client()[source]#

Get the kanban client for the active project.

Returns:

Kanban client or None if no active project.

Return type:

Optional[KanbanInterface]

async get_active_context()[source]#

Get the context for the active project.

Return type:

Optional[Context]

async get_active_events()[source]#

Get the events for the active project.

Return type:

Optional[Events]

async get_active_project_state()[source]#

Get the project state for the active project.

Return type:

Optional[ProjectState]

async get_active_assignment_persistence()[source]#

Get the assignment persistence for the active project.

Return type:

Optional[AssignmentPersistence]