src.core.context module#
Context System for Marcus.
Provides rich context for task assignments including previous implementations, dependency awareness, and relevant patterns. Enhances agent effectiveness by reducing time spent understanding existing code and architectural decisions.
- class src.core.context.TaskContext[source]#
Bases:
objectComplete context for a task assignment.
- __init__(task_id, previous_implementations=<factory>, dependent_tasks=<factory>, related_patterns=<factory>, architectural_decisions=<factory>)#
- class src.core.context.DependentTask[source]#
Bases:
objectInformation about a task that depends on another.
- class src.core.context.Decision[source]#
Bases:
objectAn architectural decision made during development.
- class src.core.context.Context[source]#
Bases:
objectManages context for task assignments.
Features: - Tracks implementations from completed tasks - Identifies dependent tasks - Stores architectural decisions - Provides rich context for new assignments - Optional persistence for long-term storage
- __init__(events=None, persistence=None, use_hybrid_inference=True, ai_engine=None, project_id=None)[source]#
Initialize the Context system.
- Parameters:
events (
Optional[Events]) – Optional Events system for integration.persistence (
Optional[Any]) – Optional Persistence instance for storing context.use_hybrid_inference (
bool) – Whether to use hybrid dependency inference if available.ai_engine (
Optional[Any]) – Optional AI engine for hybrid inference.project_id (
Optional[str]) – Project identifier for tracking decisions and artifacts.
- dependencies: Dict[str, List[DependentTask]]#
- async add_implementation(task_id, implementation)[source]#
Add implementation details from a completed task.
- add_dependency(task_id, dependent_task)[source]#
Record that one task depends on another.
- Parameters:
task_id (
str) – The task being depended upon.dependent_task (
DependentTask) – Information about the dependent task.
- Return type:
- async log_decision(agent_id, task_id, what, why, impact)[source]#
Log an architectural decision made by an agent.
- async get_context(task_id, task_dependencies)[source]#
Get complete context for a task assignment.
- Parameters:
- Returns:
Complete context for the task.
- Return type:
- async analyze_dependencies(tasks, infer_implicit=True)[source]#
Analyze task list to identify dependencies (both explicit and implicit).
- infer_needed_interface(dependent_task, dependency_task_id)[source]#
Infer what interface a dependent task needs from its dependency.
- async suggest_task_order(tasks)[source]#
Suggest an optimal order for tasks based on dependencies.
Uses topological sort with priority consideration.