# Step 8: domain-polymorphic-ownership ## Read First Read these files before editing: - `/AGENTS.md` - `/docs/AGENT_RULES.md` - `/docs/ARCHITECTURE.md` - `/docs/implementation-plans/analysis-model-objects-implementation-plan.md` - `/include/fesa/core/Domain.hpp` - all model object headers created by previous steps ## Task Extend `Domain` with RAII ownership APIs for polymorphic model objects while preserving existing definition-storage tests. Allowed files: - Modify `/include/fesa/core/Domain.hpp` - Modify `/src/core/Domain.cpp` - Create `/tests/core/domain_model_object_test.cpp` - Modify `/tests/core/domain_bootstrap_test.cpp` - Modify `/CMakeLists.txt` Required behavior: - `Domain::addElementObject(std::unique_ptr)` - `Domain::findElementObject(ElementId)` and `Domain::elementObject(ElementId)` - equivalent add/find/direct APIs for `Material`, `Load`, and model `BoundaryCondition`. - duplicate ids or duplicate load/boundary keys throw `std::invalid_argument`. - missing direct lookup throws `std::out_of_range`. - retrieval returns const base references or const base pointers. - existing `Definition` APIs remain available. ## Tests To Write First Write `/tests/core/domain_model_object_test.cpp` before production changes: - Domain owns `Mitc4Element`, `LinearElasticMaterial`, `NodalLoad`, and `SinglePointConstraint` through `std::unique_ptr`. - Find/direct lookup through base APIs works. - Duplicate ids throw for element/material. - Missing direct lookup throws. Run targeted build and confirm RED. ## Acceptance Criteria Run: ```powershell python scripts/validate_workspace.py ctest --test-dir build/msvc-debug --output-on-failure -C Debug -R model-object ctest --test-dir build/msvc-debug --output-on-failure -C Debug -R domain ``` Update step 8 status. ## Do Not - Do not remove existing definition APIs in this step. - Do not add solver state to Domain.