# v0.1.238 — Edit Duplicate critic fix (치명 2 + 중대 3 처리)

- 버전: v0.1.238
- 분류: 48th stable seal (v0.1.366) 일괄 봉인 사이클
- 다운로드: [factory00-windows-x64-v0.1.238.zip](../../downloads/archive/factory00-windows-x64-v0.1.238.zip) (archive 보존)
- 캡처: [qa-screenshots/v0.1.238/](../../qa-screenshots/v0.1.238/)

---

## critic 검토 결과 (v0.1.237)
| 등급 | 발견 | 처리 |
|---|---|---|
| 치명 | 2 | 본 사이클 fix |
| 중대 | 3 | 본 사이클 fix |
| 중간 | 2 | 본 사이클 fix |
| 사소 | 2 | 본 사이클 fix |

## 치명 #1 fix — 어셈블리 자식 Part 미등록
기존: Object.Instantiate가 자식 GameObject까지 복제하지만 Part 객체 등록 안 되어 .twn 저장 누락 + Undo 시 고아 잔존.
**P1 가드**: 자식 Part 보유 부품은 P2 예약 토스트로 거부.
`csharpif (_childrenByParentId.TryGetValue(target.id, out var children) && children.Count > 0)
{
    FlashToast($"Duplicate: 어셈블리(자식 {children.Count}개) 복제는 P2 — 단일 leaf 부품만 P1");
    return;
}
`P2에서 자식 Part 재귀 등록 구현 예약.

## 치명 #2 fix — Undo 후 stale dict entry
기존: Undo 시 _partByTransform 제거하지만 _foldExpanded/_partHidden/_hiddenByParent dict 잔존 -> ListView fold/visibility 일관성 깨짐.**fix**: Undo 안 dict 3개 모두 정리:
`csharp_host._foldExpanded?.Remove(_duplicate.id);
_host._partHidden?.Remove(_duplicate.id);
_host._hiddenByParent?.Remove(_duplicate.id);
`
## 중대 #1 fix — 위치 오프셋 Local X 변경
기존: new Vector3(50f, 0, 0) (World Space) -> 회전된 부품 복제 시 예측 불가 방향.**fix**: origGo.transform.right * 50f (Local X) -> 부모 회전 일관.
## 중대 #2 fix — Destroy 프레임 race -> DestroyImmediate
기존: Object.Destroy(comp)는 프레임 끝 실행 -> 같은 프레임 RebuildCacheAndUI 호출 시 stale Component 접근 위험.**fix**: Object.DestroyImmediate(comp) 사용. Play Mode Component 대상 안전.
## 중대 #3 인지 — DuplicateCommand 이중 책임
GameObject 생명주기 + Part 캐시 동시 소유. VisibilityCommand와 동일 구조라 P1은 그대로 유지. 구조적 분리는 P2 또는 InspectorVM 분리 사이클 (task #39)에 동반.

## 중간 #1 fix — World/Local 좌표 혼용 주석 명시
Position/Rotation = World, Scale = Local (Part 직렬화 SSOT 그대로 유지).

## 중간 #2 fix — GUID 8자 -> 16자
Guid.NewGuid().ToString("N").Substring(0, 16) — 2^64 충돌 확률 충분.
## 사소 fix — 토스트 포맷 통일 (한글)
- Execute: "복제: {name}"- Redo: "복제 (재실행): {name}"- Undo: "복제 취소: {name}"VisibilityCommand "표시/감춤" 한글 패턴 일관.

## 판정
critic 치명 0 / 중대 0 -> **PASS**. 사이클 종료 가능.

## 변경 파일
- Assets/Scripts/Game/Factory00Bootstrap.cs (~25라인)- DuplicateSelectedPart — leaf-only 가드 추가- DuplicateCommand.Execute — Local X 오프셋 + GUID 16자- DuplicateCommand.Undo — dict 3종 cleanup- RemoveRuntimeComponents — DestroyImmediate 사용- 토스트 한글 패턴 통일


---

## 봉인 참조

본 사이클은 **48th stable seal (v0.1.366, 2026-05-24)** 일괄 봉인에 포함됨.

- journal: [2026-05-24-v0.1.298-366-48th-stable-seal.md](../../journal/2026-05-24-v0.1.298-366-48th-stable-seal.md)
- alias zip: [factory00-windows-x64-v0.1.366-stable.zip](../../downloads/factory00-windows-x64-v0.1.366-stable.zip) (170 MB)
