Skip to content

Conversation

@Aditya2755
Copy link

Description

Centralize schema definitions into dedicated subpackages (schemas/runtime/ and schemas/graph/) for better reusability, separation of concerns, and cleaner imports. This refactor creates a single source of truth for data shapes while keeping behavior in the original modules.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

Related Issues

Fixes #1568

Changes Made

New Schema Structure

  • schemas/runtime/ - Runtime execution schemas

    • decision.py - Decision, DecisionType, Option, Outcome, DecisionEvaluation
    • run.py - Run, RunStatus, RunMetrics, RunSummary, Problem
  • schemas/graph/ - Graph definition schemas

    • goal.py - Goal, GoalStatus, SuccessCriterion, Constraint
    • node.py - NodeSpec
    • edge.py - EdgeCondition, EdgeSpec, AsyncEntryPointSpec, GraphSpec
    • plan.py - Plan, PlanStep, ActionSpec, ActionType, StepStatus, Judgment, and related types

Key Refactoring

  • graph/edge.py now subclasses EdgeSpec/GraphSpec from schemas and adds behavior methods (should_traverse, validate, get_node, etc.)
  • graph/goal.py, graph/node.py, graph/plan.py re-export from schemas for backward compatibility
  • schemas/__init__.py re-exports all types as a single entry point
  • Updated imports across runtime/, storage/, builder/, and tests/ to use framework.schemas

Benefits

  • Single source of truth for data shapes
  • Reuse schemas without runtime dependencies (useful for LLM prompts, API contracts, validation)
  • Clear separation: schemas = "what it is", graph/* = "what it does"
  • Backward compatible: all existing from framework.graph.* import ... still work

Testing

  • Unit tests pass (cd core && pytest tests/) - 438 tests passing
  • Lint passes (ruff check)
  • Format passes (ruff format --check)
  • Manual import verification for all schema paths

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

Import Examples

Single entry point for all schemas

from framework.schemas import Decision, Run, Goal, Plan, GraphSpec

Domain-specific imports

from framework.schemas.runtime import Decision, RunStatus
from framework.schemas.graph import Goal, Plan, EdgeSpec

Backward compatible (still works)

from framework.graph.edge import EdgeSpec, GraphSpec
from framework.graph.goal import Goal
from framework.graph.plan import Plan

Aditya2755 and others added 2 commits February 1, 2026 09:48
Centralize schema definitions for better reusability and separation of concerns:

Schema structure:
- schemas/runtime/ - decision.py, run.py (Decision, Run, RunStatus, etc.)
- schemas/graph/ - goal.py, node.py, edge.py, plan.py (Goal, Plan, GraphSpec, etc.)

Key changes:
- Move decision/run schemas from schemas/ to schemas/runtime/
- Create schemas/graph/ with goal, node, edge, plan data models
- graph/edge.py now subclasses EdgeSpec/GraphSpec and adds behavior methods
- graph/goal.py, node.py, plan.py re-export from schemas for backward compat
- schemas/__init__.py re-exports all types as single entry point
- Update imports across runtime, storage, builder, and tests

All 438 tests passing.

Fixes adenhq#1568
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor]: Centralize BaseModel schemas into schemas/ directory

1 participant