# Step 15: Generic DofManager ## 담당 역할과 필수 스킬 - 담당 역할: `implementation-agent` - 필수 스킬: `harness`, `fesa-cpp-msvc-tdd` - 이 Step만 `RED -> observed failure -> minimal GREEN -> focused/full VERIFY`로 수행한다. ## 읽어야 할 파일 - `/AGENTS.md` - `/docs/CODINGSTYLE.md` - `/docs/ARCHITECTURE.md` - `/docs/ADR.md` - `/docs/cpp-object-oriented-modular-refactoring/implementation-plan.md` - Step 13 Domain/AnalysisModel files - Step 14 `element.h`, `element_factory.h`, concrete runtime elements - `/include/fesa/fem/dof_manager.h`, `/src/fesa/fem/dof_manager.cpp` - `/tests/unit/fem/dof_manager_test.cpp` - `/tests/unit/assembly/sparse_assembler_test.cpp` - `/phases/cpp-object-oriented-modular-refactoring/index.json` - `/phases/cpp-object-oriented-modular-refactoring/step15.md` ## 작업 Requirement `R-PIPELINE-001`의 DofManager portion과 `R-DUP-002`의 DOF invariant owner를 구현한다. 1. `dof_manager_test.cpp`에 `C-DOF-001`을 먼저 추가한다. A test-only fake `Element` supplies a layout not named B33 or MITC4; DofManager must number/scatter it in source order. 2. Tests also corrupt duplicate/full/free/constrained/equation mappings through an approved test seam and expect `ValidateInvariants()` to reject each exact inconsistency. 3. Current DofManager cannot consume fake base layouts or expose owner validation, producing RED. 4. Candidate API: ```cpp Status DofManager::Build( const AnalysisModel& analysis_model, const ElementView& elements); Result> DofManager::ElementScatter( const ElementDofLayout& layout) const; Status DofManager::ValidateInvariants() const; ``` 5. Replace B33/MITC4 concrete scatter/pattern branches with the ordered layout. Node DOF ownership, constrained/free mappings, equation numbering and sparse pattern remain solely in DofManager. 6. Preserve stable node/source/component order, no/mixed/all-constraint behavior, and valid 0 free equations. Do not store equation ids in Node/Element. 7. Remove same-meaning `ValidateDofOrder` helpers from other modules only after their callers use `ValidateInvariants()` or an owner-issued immutable mapping. ## Acceptance Criteria ```powershell cmake --build .harness/build --config Debug --target fesa_unit_tests ctest --test-dir .harness/build -C Debug ` -R "DofManager|EssentialConstraints|SparseAssembly" --output-on-failure $typeBranches = @(rg -n "EulerBeam3D|Mitc4Shell" src/fesa/fem/dof_manager.cpp) if ($typeBranches.Count -ne 0) { $typeBranches; throw "Concrete element branch remains" } rg -n "ValidateDofOrder" src/fesa & "C:/Program Files/LLVM/bin/clang-format.exe" --dry-run --Werror ` include/fesa/fem/dof_manager.h src/fesa/fem/dof_manager.cpp ` tests/unit/fem/dof_manager_test.cpp cmake --build .harness/build --config Debug ctest --test-dir .harness/build -C Debug --show-only=json-v1 ctest --test-dir .harness/build -C Debug --output-on-failure ``` `ValidateDofOrder` scan must show no duplicate local definitions. Existing public compatibility wrappers may remain temporarily only if they delegate to DofManager and are removed by Step 20. ## 검증 및 상태 갱신 - RED fake-element/invariant failures, focused stable ordering, branch scan and full CTest를 summary에 기록한다. - Equation or sparse pattern ordering regression is `error`. - 성공 시 현재 Step만 `completed`로 갱신한다. - timestamp, retry, commit, advancement는 Executor 소유다. ## 금지사항 - Element에 equation ids or global CSR를 저장하지 마라. - DOF component order를 element kind switch로 재구성하지 마라. - Sparse assembly algorithm을 수정하지 마라. 이유: Step 16 소유다. - 직접 commit하거나 hook script를 수동 실행하지 마라.