# Step 23: HDF5 Results Writer ## 담당 역할과 필수 스킬 - 담당 역할: `implementation-agent` - 필수 스킬: `fesa-cpp-msvc-tdd` - 모든 C++ build/test와 최종 VERIFY는 MSVC x64 Debug 기준으로 수행한다. ## 읽어야 할 파일 - `/AGENTS.md` - `/docs/ARCHITECTURE.md` - `/docs/ADR.md` - `/docs/linear-static-3d-euler-beam/requirements.md` - `/docs/linear-static-3d-euler-beam/io.md` - `/docs/linear-static-3d-euler-beam/implementation-plan.md` - `/include/fesa/core/diagnostic.hpp` - `/include/fesa/model/domain.hpp` - `/include/fesa/analysis/analysis_state.hpp` - `/include/fesa/results/result_records.hpp` - `/cmake/FesaDependencies.cmake` ## 소유 파일 - Create: `/include/fesa/results/results_writer.hpp` - Create: `/include/fesa/io/hdf5/hdf5_results_writer.hpp` - Create: `/src/fesa/io/hdf5/hdf5_results_writer.cpp` - Create: `/tests/unit/results/results_writer_test.cpp` - Create: `/tests/unit/io/hdf5/hdf5_results_writer_test.cpp` - Modify: `/src/fesa/CMakeLists.txt` - Modify: `/tests/CMakeLists.txt` ## 작업 HDF5 API를 adapter 안에 숨기고 schema v0를 임시 파일에 완성한 후 final path로 교체하는 ResultsWriter를 구현하라. ```cpp class ResultsWriter { public: virtual ~ResultsWriter() = default; virtual Status write(const std::filesystem::path& outputPath, const Domain& domain, const AnalysisState& state, const std::vector& diagnostics) = 0; }; class Hdf5ResultsWriter final : public ResultsWriter { public: Status write(const std::filesystem::path& outputPath, const Domain& domain, const AnalysisState& state, const std::vector& diagnostics) override; }; ``` 다음 group/dataset을 exact path와 승인 shape/component order로 기록한다. ```text /metadata /model/nodes /model/elements /steps//frames/0/nodal/displacement /steps//frames/0/nodal/reaction /steps//frames/0/element/end_force_local /steps//frames/0/element/section_resultant /steps//frames/0/element/generalized_strain /steps//frames/0/element/generalized_resultant /steps//frames/0/element/stress_s11 /diagnostics ``` 승인 설계의 schema 목록은 minimum contract이며, 별도 `generalized_resultant` dataset은 설계가 요구한 Gauss-point generalized resultant를 손실 없이 기록하기 위한 필수 sibling이다. Metadata는 schema/solver version, source input identity, `user-consistent-unspecified` unit label, coordinate convention, `B33 Euler-Bernoulli` formulation을 가진다. Model rows는 stable internal ID와 instance/source label을 함께 쓴다. 모든 field에는 component/output-location identity를 기록한다. HDF5 handle은 RAII로 닫고 failure 시 incomplete final `results.h5`를 남기지 않는다. Existing final 교체도 Windows에서 실패 중간 상태를 만들지 않는 adapter 내 정책과 test를 제공한다. HDF5/Windows API type은 public header에 노출하지 않는다. Tests는 complete schema/shape/metadata/identity/component, diagnostics warning, no section points centroid, failed path/no partial final, successful replacement을 포함하고 `Hdf5ResultsWriter` regex로 등록한다. ## Acceptance Criteria ```powershell cmake --build .harness/build --config Debug --target fesa_tests ctest --test-dir .harness/build -C Debug -R Hdf5ResultsWriter --output-on-failure ``` RED 후 GREEN/VERIFY: ```powershell cmake -S . -B .harness/build -A x64 ` -DFESA_GTEST_SOURCE_DIR=C:/git/googletest ` "-DMKL_DIR=C:/Program Files (x86)/Intel/oneAPI/mkl/2026.1/lib/cmake/mkl" ` "-DTBB_DIR=C:/Program Files (x86)/Intel/oneAPI/tbb/2023.1/lib/cmake/tbb" ` "-DHDF5_DIR=C:/Program Files/HDF_Group/HDF5/2.1.1/cmake" cmake --build .harness/build --config Debug ctest --test-dir .harness/build -C Debug -R Hdf5ResultsWriter --output-on-failure ctest --test-dir .harness/build -C Debug --show-only=json-v1 ctest --test-dir .harness/build -C Debug --output-on-failure $leaks = rg -n "H5[A-Z_a-z0-9]*|hid_t" include/fesa if ($LASTEXITCODE -eq 0) { throw "HDF5 API leaked into public headers:`n$leaks" } if ($LASTEXITCODE -ne 1) { throw 'Public-header dependency scan failed' } ``` 마지막 scan은 public header에서 no-match여야 한다. ## 검증 절차 1. schema/atomicity tests를 먼저 작성하고 writer 부재 RED를 확인한다. 2. exact schema와 RAII/temporary finalization의 최소 구현으로 GREEN을 만든다. 3. HDF5 inspection, failure cleanup, public boundary와 전체 VERIFY를 확인한다. 4. `/docs/linear-static-3d-euler-beam/implementation-report.md`의 Step 23 section에 실제 RED/GREEN/VERIFY command, exit code, 핵심 output과 변경 파일을 기록한다. 5. Step 23을 `completed`로 갱신하고 schema/atomicity evidence를 summary에 기록한다. ## 금지사항 - CSV를 공식 solver output으로 추가하지 마라. 이유: authoritative output은 HDF5 하나다. - Abaqus output request로 dataset을 생략하지 마라. 이유: FESA default output은 항상 생성된다. - HDF5 type/header를 public API에 노출하지 마라. 이유: adapter boundary 계약이다. - 실패 후 incomplete final file을 남기지 마라. 이유: output integrity 계약이다. - 직접 commit하지 마라. 이유: Harness executor가 담당한다.