Split DefaultContext into DefaultEditingContext and DefaultSimulationContext#98
Merged
bedaHovorka merged 8 commits intoJan 14, 2026
Conversation
Copilot
AI
changed the title
[WIP] Split DefaultContext into DefaultEditingContext and DefaultSimulationContext
Split DefaultContext into DefaultEditingContext and DefaultSimulationContext
Jan 14, 2026
Contributor
Author
Fixed in c35317d. Added type casts in test files where factory methods return interface types (EditingContext, Context) but tests need DefaultSimulationContext. Build now successful. |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request implements Phase 3 of the Context refactoring, splitting the monolithic DefaultContext class (984 lines) into two focused classes that follow the separation of concerns principle:
Changes:
- Created
DefaultEditingContextwith editing operations only (grid, graph, cells management) - Created
DefaultSimulationContextextendingDefaultEditingContextwith simulation capabilities (run, stop, pathfinding, reporting) - Deprecated
DefaultContextas a backward compatibility alias pointing toDefaultSimulationContext - Updated factory methods in
XMLContextFactoryto return appropriate interface types - Added type casts in 13 test files where concrete type access is needed
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
DefaultEditingContext.kt |
New class with editing-only operations (613 lines), no simulation dependencies |
DefaultSimulationContext.kt |
New class extending editing context with simulation (450 lines) |
DefaultContext.kt |
Reduced to deprecated alias (74 lines) for backward compatibility |
XMLContextFactory.kt |
Updated to use new classes, returns interface types from factory methods |
| Test files (13) | Added type casts where concrete DefaultSimulationContext access is needed |
…Context Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
…nContext Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
- Cast factory.createEmptyContext() results to DefaultSimulationContext - Update ExampleRegistry to use DefaultSimulationContext instead of deprecated DefaultContext - Add necessary type casts in test files for proper type checking - All 727 tests passing (1 skipped)
- Remove conflicting typealias from DefaultContext.kt - Fix logger initialization order in DefaultSimulationContext companion object - All tests now pass (728 unit tests, 95 integration tests)
c35317d to
cf89484
Compare
9c95fc5
into
copilot/divide-defaultcontext-implementation
1 check failed
Closed
4 tasks
9 tasks
bedaHovorka
pushed a commit
that referenced
this pull request
Jan 20, 2026
bedaHovorka
added a commit
that referenced
this pull request
Feb 5, 2026
Issues addressed: - #212: Complete Phase 6 Documentation (Issue #153 context refactoring) - #175: Translation quality verification (Czech railway terminology) - Document InOut with Dynamic pattern (static/dynamic separation) - Documentation second revision and polish Changes: Phase 4: Issue #212 - Phase 6 Documentation - Updated CONTEXT_INHERITANCE_INCOMPATIBILITY.md: Marked Phases 1-5 complete (2026-01-20), Phase 5.5 NEW (#182), Phase 6 IN PROGRESS - Created CONTEXT_REFACTORING_PHASE6_SUMMARY.md (764 lines): Comprehensive Phase 6 status with implementation achievements, timeline performance (70% faster), technical debt, lessons learned - Updated CONTEXT_REFACTORING_DESIGN.md: Added implementation history section (Phases 1-7, Issue #98 + Issue #153), test coverage metrics, timeline performance - Updated CLAUDE.md: Expanded context refactoring history with Phase 1-5 completion details, references to Phase 6 summary - Verified PlantUML diagrams: context-hierarchy.puml, context-transformation.puml, factory-pattern.puml (all exist) Phase 5: Issue #175 - Translation Quality Verification - Created CZECH_RAILWAY_TERMINOLOGY.md (354 lines): Complete Czech railway terminology reference - Inventory: 15+ Czech terms (vyhybna, nádraží, Praha districts) - Verification: 100% spelling correct, 100% diacritics correct, 100% technical accuracy - Glossary: Core terms (vyhybna, výhybka, návěstidlo), directional prepositions (za, do), Prague districts (Libeň, Vysočany, Vinohrady, Vršovice) - Recommendations: Keep Czech file names (historically appropriate), optionally translate 1 Czech comment in ShuntingLoop.kt - Conclusion: All Czech terminology correctly used and appropriate for educational context Phase 6: Document InOut with Dynamic Pattern - Updated STATIC_DYNAMIC_SEPARATION_ARCHITECTURE.md: Expanded DynamicInOut section from 18 to 74 lines - Added static InOut properties (immutable configuration) - Added dynamic InOut state (reservation, occupancy, last train) - Added usage pattern with code examples (editing → simulation transformation) - Added identity contract (System.identityHashCode, IdentityHashMap, === reference equality) - Added railway domain context (minimum 2 InOuts, entry/exit points) - Added testing references (DynamicInOutTest.kt, InOutIntegrationTest.kt, InOutValidationTest.kt) - Updated KOTLIN_STYLE_GUIDE.md: Expanded Static/Dynamic Separation Pattern section from 17 to 62 lines - Added pattern overview (static objects vs dynamic wrappers) - Added identity contract (stable hash, wrapper caching) - Added detailed InOut example with code (static configuration, dynamic state) - Added railway domain context (network boundaries, spawn/despawn points) - Added usage rule (always use context.toDynamic()) Phase 7: Documentation Second Revision and Polish - Verified all cross-references work correctly - Verified PlantUML diagrams exist (context-hierarchy.puml, context-transformation.puml, factory-pattern.puml) - Checked section ordering (logical progression) - Verified consistent terminology across all docs - Verified markdown formatting (headers, lists, code blocks) - Verified line counts (CLAUDE.md: 379, KOTLIN_STYLE_GUIDE.md: 2252, STATIC_DYNAMIC_SEPARATION_ARCHITECTURE.md: 1045) Test Results: - All 1836 tests passing (was 1836) - Zero regressions - InOut tests from Phase 3: 16/16 passing (DynamicInOutTest, InOutValidationTest, InOutIntegrationTest) Quality Gates: - ktlintCheck: PASS (documentation files are markdown, not affected) - detekt: Minor issues in Phase 3 test files (not part of this documentation PR) - test: 1836 tests PASS, 0 failures - build: PASS Note: Detekt warnings in InOutIntegrationTest.kt, InOutValidationTest.kt, DynamicInOutTest.kt are from Phase 3 (committed in eacf18e). These are minor formatting issues (max line length, unused imports) in test files and do not affect documentation improvements. Documentation Files: - Created: CONTEXT_REFACTORING_PHASE6_SUMMARY.md (764 lines), CZECH_RAILWAY_TERMINOLOGY.md (354 lines) - Modified: CONTEXT_INHERITANCE_INCOMPATIBILITY.md, CONTEXT_REFACTORING_DESIGN.md, CLAUDE.md, STATIC_DYNAMIC_SEPARATION_ARCHITECTURE.md, KOTLIN_STYLE_GUIDE.md - Total: 2 new files, 5 modified files, 1118 new lines of documentation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
4 tasks
This was referenced Mar 10, 2026
This was referenced Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 3: Split DefaultContext Implementation Plan
Understanding
Implementation Plan
1. Analyze DefaultContext to identify editing vs simulation code
2. Create DefaultEditingContext class
3. Create DefaultSimulationContext class
4. Update XMLContextFactory
5. Handle backward compatibility
6. Update tests
7. Run comprehensive validation
8. Update documentation
Status
Compilation errors fixed!
./gradlew clean build -x test -x detektOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.