Skip to content

chore: migrate scenarios to Pydantic — 40 classes, -658 LOC — completes migration (AC-489, AC-481)#599

Merged
jayscambler merged 2 commits intomainfrom
chore/pydantic-migration-scenarios
Apr 1, 2026
Merged

chore: migrate scenarios to Pydantic — 40 classes, -658 LOC — completes migration (AC-489, AC-481)#599
jayscambler merged 2 commits intomainfrom
chore/pydantic-migration-scenarios

Conversation

@jayscambler
Copy link
Copy Markdown
Contributor

Summary

Final Pydantic migration batch — converted 40 scenario data classes to BaseModel. -658 LOC net. This completes the bulk of the to_dict/from_dict elimination.

Changes

13 files, 40 classes:

File Classes
simulation.py ActionTrace, SimulationResult
workflow.py WorkflowStep, SideEffect, CompensationAction, WorkflowResult
tool_fragility.py ToolContract, ToolDrift, FailureAttribution, ToolFragilityResult
negotiation.py HiddenPreferences, NegotiationRound, OpponentModel, NegotiationResult
schema_evolution.py SchemaMutation, ContextValidity, SchemaEvolutionResult
operator_loop.py ClarificationRequest, EscalationEvent, OperatorLoopResult
investigation.py EvidenceItem, EvidenceChain, InvestigationResult
coordination.py WorkerContext, HandoffRecord, CoordinationResult
artifact_editing.py Artifact, ArtifactDiff, ArtifactEditingResult
world_state.py WorldEntity, WorldResource, DependencyEdge, HiddenVariable, StateDelta, StateTransition, WorldState
templates/__init__.py RubricDimension, TemplateSpec
custom/spec.py ScenarioSpec
custom/family_classifier.py FamilyClassification

Kept as @DataClass

  • ABC interface classes (SimulationInterface, etc.)
  • WorldStateManager, WorldStateStore (plain classes with private state)
  • ActionSpec, Action, ActionResult, ActionRecord, EnvironmentSpec (used with dataclasses.replace/asdict)

Pydantic Migration Complete

Module Classes LOC saved PR
analytics/ 36 -630 #593, #594
knowledge/ 17 -285 #595
harness/ 12 -155 #596
execution/ 24 -316 #597
agents/providers/misc 18 -267 #598
scenarios/ 40 -658 #599
Total 147 -2,311

Verification

  • ruff check src — all checks passed
  • mypy src — zero errors
  • pytest tests/ — all tests pass (1 pre-existing flaky heartbeat test excluded)

Issues

Completes AC-489 and AC-481 for all major modules.

…C-481)

Converted 40 dataclasses across 13 scenario files from @DataClass to
Pydantic BaseModel. Eliminates ~684 lines of to_dict/from_dict.

Files: simulation.py, workflow.py, tool_fragility.py, negotiation.py,
schema_evolution.py, operator_loop.py, investigation.py, coordination.py,
artifact_editing.py, world_state.py, templates/__init__.py,
custom/spec.py, custom/family_classifier.py

NOT converted (ABC hierarchies):
- SimulationInterface, WorkflowInterface, etc. (abstract classes)
- WorldStateManager, WorldStateStore (plain classes)
- ActionSpec, Action, ActionResult, ActionRecord, EnvironmentSpec
  (kept as @DataClass — used with dataclasses.replace/asdict)

TDD: Extended test_serde_conventions.py with scenarios module enforcement.

14 files changed, 196 insertions, 854 deletions (-658 net)
@jayscambler jayscambler merged commit 6ff5cdb into main Apr 1, 2026
4 checks passed
@jayscambler jayscambler deleted the chore/pydantic-migration-scenarios branch April 1, 2026 17:09
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.

1 participant