<!-- task=02+yaml_validation plan=2 tag=REVIEW_REVIEW_REFACTOR -->

# Code Review Reference - REVIEW_REVIEW_REFACTOR

> **[IMPLEMENTING AGENT — READ FIRST] Filling in this file is the mandatory final step of implementation.**
> The task is NOT complete until every implementation-owned section below is filled in.
> Complete the `구현 체크리스트`; the final checklist item is mandatory before saving.
> Do not modify or check the `코드리뷰 전용 체크리스트`; it is owned by the review agent only.
> Follow the ownership table at the bottom of this file for which sections you own.

## 개요

date=2026-05-20
task=02+yaml_validation, plan=2, tag=REVIEW_REVIEW_REFACTOR

## 이 파일을 읽는 리뷰 에이전트에게

각 항목의 구현을 실제 소스 파일과 대조하고, `검증 결과` 섹션의 출력이 코드와 일치하는지 확인하세요.
Review 완료 후 반드시 아래 순서로 아카이브하세요.

1. `CODE_REVIEW-cloud-G07.md` → `code_review_cloud_G07_N.log` (N = 기존 code_review_*.log 수)
2. `PLAN-cloud-G07.md` → `plan_cloud_G07_M.log` (M = 기존 plan_*.log 수)
3. PASS인 경우 `complete.log` 작성 후 `agent-task/archive/YYYY/MM/02+yaml_validation/`로 task 디렉터리 이동. WARN/FAIL인 경우 새 routed plan + review 스텁 작성.

판정 append만으로 review를 끝내면 안 됩니다. `PASS`, `WARN`, `FAIL` 모두 active plan/review 파일을 `.log`로 전환한 뒤 다음 상태 파일까지 만든 후에만 보고하세요.
어떤 판정에서도 아카이브를 건너뛰지 마세요. PASS/WARN/FAIL 모두 `코드리뷰 결과` append 후 active plan/review 파일을 먼저 아카이브하고, 그 다음 `complete.log` 또는 다음 plan/review 파일을 작성해야 합니다.
PASS에서는 `agent-ops/skills/common/code-review/templates/complete-log-template.md`의 섹션 순서와 필수 항목을 기준으로 `complete.log`를 작성하세요. 작성 후 현재 날짜의 `YYYY/MM` 기준으로 task 디렉터리를 `agent-task/archive/YYYY/MM/02+yaml_validation/`로 이동하고, 최종 archive 경로의 `code_review_*.log`에서 `코드리뷰 전용 체크리스트`를 갱신한 다음 보고하세요.
WARN/FAIL에서는 다음 상태 파일 작성 후 현재 task 경로의 archived `code_review_*.log`에서 적용 가능한 `코드리뷰 전용 체크리스트` 항목을 체크한 다음 보고하세요.

---

## 구현 항목별 완료 여부

| 항목 | 완료 여부 |
|------|---------|
| [REVIEW_REVIEW_REFACTOR-1] nested YAML map 변환 안전화 | [x] |
| [REVIEW_REVIEW_REFACTOR-2] workflow key validation message 고정 | [x] |

## 구현 체크리스트

- [x] nested `YamlMap`/`YamlList` 변환이 non-string workflow key에서 raw `jsonEncode` 예외를 내지 않게 한다.
- [x] non-string workflow task key가 `workflow[index]`를 포함한 validation message로 실패하게 한다.
- [x] non-string workflow task key 테스트와 기존 최종 검증을 실행한다.
- [x] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.

## 코드리뷰 전용 체크리스트

> **[REVIEW AGENT ONLY]** 이 체크리스트는 코드리뷰 에이전트만 사용한다.
> 구현 에이전트는 이 섹션을 수정하거나 체크하지 않는다.

- [x] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다.
- [x] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다.
- [x] active `CODE_REVIEW-*-G??.md`를 `code_review_cloud_G07_N.log`로 아카이브한다.
- [x] active `PLAN-*-G??.md`를 `plan_cloud_G07_M.log`로 아카이브한다.
- [x] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다.
- [x] PASS이면 `agent-task/02+yaml_validation/`를 `agent-task/archive/YYYY/MM/02+yaml_validation/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다.
- [ ] WARN/FAIL이면 다음 active `PLAN-cloud-G07.md`와 `CODE_REVIEW-cloud-G07.md`를 작성하고 `complete.log`를 작성하지 않는다.

## 계획 대비 변경 사항

- `dart:convert` import를 제거했다. `jsonEncode`/`jsonDecode`를 `_yamlToPlain()` 재귀 헬퍼로 대체했으므로 더 이상 필요하지 않다.

## 주요 설계 결정

- **REVIEW_REVIEW_REFACTOR-1**: `getMapFromYamlA()`에서 `jsonDecode(jsonEncode(data))` 대신 `_yamlToPlain()` 재귀 헬퍼를 사용한다. `YamlMap` key를 `e.key.toString()`으로 변환하고, `YamlList`는 재귀 변환한다. non-string key(예: `123`)는 `"123"`으로 변환되어 `Pipeline.pipelineInitialize()`에 전달된다.
- **REVIEW_REVIEW_REFACTOR-2**: `Pipeline.pipelineInitialize()`에서 `"123"`은 `exeMap`에 없으므로 기존 메시지 `workflow[0]: "123" is not a supported task. Supported tasks: ...`로 실패한다. 별도 수정 없이 REVIEW_REVIEW_REFACTOR-1 구현만으로 validation message 계약이 충족된다.
- 테스트에서 `result.error.toString()`이 `Converting object to an encodable object failed`를 포함하지 않고 `workflow[0]`을 포함하는지 단언한다.

## 리뷰어를 위한 체크포인트

- `pipeline.workflow`에 숫자 task key가 있어도 `jsonEncode` raw error가 노출되지 않는지 확인한다.
- 실패 메시지에 `workflow[0]` 또는 `Validate Pipeline` 및 unsupported task 정보가 포함되는지 확인한다.
- 기존 root/property/command id/type invalid YAML 테스트가 계속 통과하는지 확인한다.
- 정상 샘플 smoke가 계속 `Build Successfully Complete`를 출력하는지 확인한다.

## 검증 결과

필수 규칙:
- 검증 명령은 고정된 계약이다. 임의로 대체하지 않는다.
- 대체가 필요하면 `계획 대비 변경 사항`에 이유와 대체 명령을 기록한다.
- `검증 결과`에는 실제 stdout/stderr를 붙여 넣는다.

### REVIEW_REVIEW_REFACTOR-1 중간 검증
```
$ dart test test/oto_application_test.dart test/oto_core_test.dart
00:00 +0: loading test/oto_application_test.dart
00:00 +0: test/oto_application_test.dart: build returns failure instead of exiting on invalid yaml
00:00 +1: test/oto_application_test.dart: build returns failure instead of exiting on invalid yaml
00:00 +2: test/oto_application_test.dart: build returns failure instead of exiting on invalid yaml
00:00 +3: test/oto_application_test.dart: build returns failure instead of exiting on invalid yaml
00:00 +3: test/oto_application_test.dart: build returns failure instead of exiting on invalid yaml
*********************************  Build Data  *************************************


property:
  workspace: .
commands:
  - command: Print
    id: hello
    param:
      message: hi
pipeline:
  id: main
  workflow:
    - exe: doesNotExist

Exception:  [Validate Pipeline]

The doesNotExist command does not exist in the command list.


#0      Application.build (package:oto/oto/application.dart:148:9)
<asynchronous suspension>
#1      main.<anonymous closure> (file:///config/workspace/oto/test/oto_application_test.dart:30:9)
<asynchronous suspension>
#2      Declarer.test.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:242:9)
<asynchronous suspension>
#3      Declarer.test.<anonymous closure> (package:test_api/src/backend/declarer.dart:240:7)
<asynchronous suspension>
#4      Invoker._waitForOutstandingCallbacks.<anonymous closure> (package:test_api/src/backend/invoker.dart:282:9)
<asynchronous suspension>



*********************************************************************************************
*                            Build Failed
*********************************************************************************************


00:00 +4: test/oto_application_test.dart: build returns failure instead of exiting on invalid yaml
00:00 +4: test/oto_application_test.dart: file build returns success for print-only pipeline
00:00 +4: test/oto_application_test.dart: file build returns success for print-only pipeline
*********************************  Build Data  *************************************


property:
  workspace: .
commands:
  - command: Print
    id: hello
    param:
      message: hi
pipeline:
  id: main
  workflow:
    - exe: hello

*********************************************************************************************
*                            Phase Start: Print (hello)
*********************************************************************************************


hi
*********************************************************************************************
*                            Build Successfully Complete
*********************************************************************************************


00:00 +5: test/oto_application_test.dart: file build returns success for print-only pipeline
00:00 +5: test/oto_application_test.dart: file build can run twice in same process
00:00 +5: test/oto_application_test.dart: file build can run twice in same process
*********************************  Build Data  *************************************


property:
  workspace: .
commands:
  - command: Print
    id: hello
    param:
      message: hi
pipeline:
  id: main
  workflow:
    - exe: hello

*********************************************************************************************
*                            Phase Start: Print (hello)
*********************************************************************************************


hi
*********************************************************************************************
*                            Build Successfully Complete
*********************************************************************************************


*********************************  Build Data  *************************************


property:
  workspace: .
commands:
  - command: Print
    id: hello
    param:
      message: hi
pipeline:
  id: main
  workflow:
    - exe: hello

*********************************************************************************************
*                            Phase Start: Print (hello)
*********************************************************************************************


hi
*********************************************************************************************
*                            Build Successfully Complete
*********************************************************************************************


00:00 +6: test/oto_application_test.dart: file build can run twice in same process
00:00 +6: test/oto_application_test.dart: build fails with message when YAML root is not a map
00:00 +6: test/oto_application_test.dart: build fails with message when YAML root is not a map
Exception:  [Validate build yaml]

Build YAML root must be a map.


#0      Application.build (package:oto/oto/application.dart:104:11)
<asynchronous suspension>
#1      main.<anonymous closure> (file:///config/workspace/oto/test/oto_application_test.dart:89:9)
<asynchronous suspension>
#2      Declarer.test.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:242:9)
<asynchronous suspension>
#3      Declarer.test.<anonymous closure> (package:test_api/src/backend/declarer.dart:240:7)
<asynchronous suspension>
#4      Invoker._waitForOutstandingCallbacks.<anonymous closure> (package:test_api/src/backend/invoker.dart:282:9)
<asynchronous suspension>



*********************************************************************************************
*                            Build Failed
*********************************************************************************************


00:00 +7: test/oto_application_test.dart: build fails with message when YAML root is not a map
00:00 +7: test/oto_application_test.dart: build fails with message when property is not a map
00:00 +7: test/oto_application_test.dart: build fails with message when property is not a map
Exception:  [Validate build yaml]

property must be a map, got: List<dynamic>.


#0      Application.build (package:oto/oto/application.dart:104:11)
<asynchronous suspension>
#1      main.<anonymous closure> (file:///config/workspace/oto/test/oto_application_test.dart:109:9)
<asynchronous suspension>
#2      Declarer.test.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:242:9)
<asynchronous suspension>
#3      Declarer.test.<anonymous closure> (package:test_api/src/backend/declarer.dart:240:7)
<asynchronous suspension>
#4      Invoker._waitForOutstandingCallbacks.<anonymous closure> (package:test_api/src/backend/invoker.dart:282:9)
<asynchronous suspension>



*********************************************************************************************
*                            Build Failed
*********************************************************************************************


00:00 +8: test/oto_application_test.dart: build fails with message when property is not a map
00:00 +8: test/oto_application_test.dart: build fails with message when command id is not a string
00:00 +8: test/oto_application_test.dart: build fails with message when command id is not a string
Exception:  [Validate command list]

commands[0] id must be a non-empty string.


#0      Application.build (package:oto/oto/application.dart:112:11)
<asynchronous suspension>
#1      main.<anonymous closure> (file:///config/workspace/oto/test/oto_application_test.dart:127:9)
<asynchronous suspension>
#2      Declarer.test.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:242:9)
<asynchronous suspension>
#3      Declarer.test.<anonymous closure> (package:test_api/src/backend/declarer.dart:240:7)
<asynchronous suspension>
#4      Invoker._waitForOutstandingCallbacks.<anonymous closure> (package:test_api/src/backend/invoker.dart:282:9)
<asynchronous suspension>



*********************************************************************************************
*                            Build Failed
*********************************************************************************************


00:00 +9: test/oto_application_test.dart: build fails with message when command id is not a string
00:00 +9: test/oto_application_test.dart: build fails with message when command type is not a string
00:00 +9: test/oto_application_test.dart: build fails with message when command type is not a string
Exception:  [Validate command list]

commands[0] (id: hello) command must be a non-empty string.


#0      Application.build (package:oto/oto/application.dart:112:11)
<asynchronous suspension>
#1      main.<anonymous closure> (file:///config/workspace/oto/test/oto_application_test.dart:145:9)
<asynchronous suspension>
#2      Declarer.test.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:242:9)
<asynchronous suspension>
#3      Declarer.test.<anonymous closure> (package:test_api/src/backend/declarer.dart:240:7)
<asynchronous suspension>
#4      Invoker._waitForOutstandingCallbacks.<anonymous closure> (package:test_api/src/backend/invoker.dart:282:9)
<asynchronous suspension>



*********************************************************************************************
*                            Build Failed
*********************************************************************************************


00:00 +10: test/oto_application_test.dart: build fails with message when command type is not a string
00:00 +10: test/oto_application_test.dart: build fails with validation message when workflow key is not a string
00:00 +10: test/oto_application_test.dart: build fails with validation message when workflow key is not a string
*********************************  Build Data  *************************************


commands:
  - command: Print
    id: hello
    param:
      message: hi
pipeline:
  id: main
  workflow:
    - 123: hello

Exception:  [Validate Pipeline]

workflow[0]: 123 is not a supported task. Supported tasks: exe, exe-handle, async, if, contain, while, foreach, wait-until-int, wait-until-float, wait-until-double, wait-until-string, wait-until-seconds, switch.


#0      Application.build (package:oto/oto/application.dart:148:9)
<asynchronous suspension>
#1      main.<anonymous closure> (file:///config/workspace/oto/test/oto_application_test.dart:164:9)
<asynchronous suspension>
#2      Declarer.test.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:242:9)
<asynchronous suspension>
#3      Declarer.test.<anonymous closure> (package:test_api/src/backend/declarer.dart:240:7)
<asynchronous suspension>
#4      Invoker._waitForOutstandingCallbacks.<anonymous closure> (package:test_api/src/backend/invoker.dart:282:9)
<asynchronous suspension>



*********************************************************************************************
*                            Build Failed
*********************************************************************************************


00:00 +11: test/oto_application_test.dart: build fails with validation message when workflow key is not a string
00:00 +11: test/oto_application_test.dart: CommandExe exe -f handles missing file without LateInitializationError
00:00 +11: test/oto_application_test.dart: CommandExe exe -f handles missing file without LateInitializationError
There are no files in path /tmp/oto_missing_1779245127332111.yaml


00:00 +12: test/oto_application_test.dart: CommandExe exe -f handles missing file without LateInitializationError
00:00 +12: All tests passed!
```

### REVIEW_REVIEW_REFACTOR-2 중간 검증
```
$ dart test test/oto_application_test.dart test/oto_core_test.dart
(REVIEW_REVIEW_REFACTOR-1과 동일한 실행. +12: All tests passed!)
```

### 최종 검증
```
$ dart analyze
Analyzing oto...
No issues found!

$ dart test test/oto_application_test.dart test/oto_core_test.dart
(REVIEW_REVIEW_REFACTOR-1 중간 검증과 동일. +12: All tests passed!)

$ dart run bin/main.dart exe -f assets/yaml/sample/01_basic.yaml
Execute command: exe, Arguments: [-f, assets/yaml/sample/01_basic.yaml]


*********************************  Build Data  *************************************


---
# [샘플] 기본 구조
# property, commands, pipeline 세 섹션으로 구성된다.
# pipeline의 exe는 commands의 id를 참조한다.

property:
  workspace: /path/to/project
  env: dev
  version: 1.0.0

pipeline:
  id: main
  workflow:
  - exe: print-start
  - exe: set-value
  - exe: print-result

commands:
- command: Print
  id: print-start
  param:
    message: "빌드 시작 - env: <!property.env>, version: <!property.version>"

- command: SetValue
  id: set-value
  param:
    values-string:
      buildTag: "v<!property.version>-<!property.env>"
    values-int:
      retryCount: 0
    values-bool:
      isRelease: false

- command: Print
  id: print-result
  param:
    message: "빌드 태그: <!property.buildTag>"

*********************************************************************************************
*                            Phase Start: Print (print-start)
*********************************************************************************************


빌드 시작 - env: dev, version: 1.0.0
*********************************************************************************************
*                            Phase Start: SetValue (set-value)
*********************************************************************************************


[Return] isRelease : false
[Return] retryCount : 0
[Return] buildTag : v1.0.0-dev
*********************************************************************************************
*                            Phase Start: Print (print-result)
*********************************************************************************************


빌드 태그: v1.0.0-dev
*********************************************************************************************
*                            Build Successfully Complete
*********************************************************************************************

$ dart run bin/main.dart exe -f assets/yaml/sample/02_pipeline_if.yaml
Execute command: exe, Arguments: [-f, assets/yaml/sample/02_pipeline_if.yaml]


*********************************  Build Data  *************************************


---
# [샘플] 조건 분기 (if)
# condition-string / condition-int / condition-float / condition-bool /
# condition-date / condition-version 으로 타입 지정
# on-true / on-false 로 분기

property:
  workspace: /path/to/project
  env: prod
  retryCount: 0
  version: 2.1.0

pipeline:
  id: main
  workflow:
  # string 비교
  - if:
      condition-string: <!property.env> == prod
      on-true:
      - exe: deploy-prod
      on-false:
      - exe: deploy-dev

  # int 비교
  - if:
      condition-int: <!property.retryCount> < 3
      on-true:
      - exe: retry-build

  # version 비교 (자릿수 동일해야 함: 0.0.0 or 0.0.0.0)
  - if:
      condition-version: <!property.version> >= 2.0.0
      on-true:
      - exe: new-flow

commands:
- command: Print
  id: deploy-prod
  param:
    message: "운영 배포 실행"

- command: Print
  id: deploy-dev
  param:
    message: "개발 배포 실행"

- command: Print
  id: retry-build
  param:
    message: "재시도 실행"

- command: Print
  id: new-flow
  param:
    message: "신규 플로우 실행"

[Pipeline-IF]


 - Condition: <!property.env> == prod
 - Values:    prod == prod
 - Result:    true ===> Execute: on-true 
*********************************************************************************************
*                            Phase Start: Print (deploy-prod)
*********************************************************************************************


운영 배포 실행
[Pipeline-IF]


 - Condition: <!property.retryCount> < 3
 - Values:    0 < 3
 - Result:    true ===> Execute: on-true 
*********************************************************************************************
*                            Phase Start: Print (retry-build)
*********************************************************************************************


재시도 실행
[Pipeline-IF]


 - Condition: <!property.version> >= 2.0.0
 - Values:    2.1.0 >= 2.0.0
 - Result:    true ===> Execute: on-true 
*********************************************************************************************
*                            Phase Start: Print (new-flow)
*********************************************************************************************


신규 플로우 실행
*********************************************************************************************
*                            Build Successfully Complete
*********************************************************************************************
```

---

> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section: completion table, implementation checklist, changes from plan, design decisions, and verification output?**
> If anything is blank, go back and fill it in before saving this file.
> Leave the review-agent-only checklist unchanged.

## 코드리뷰 결과

### 2026-05-20 - Review 2

- 종합 판정: PASS

- 차원별 평가:
  - Correctness: Pass
  - Completeness: Pass
  - Test coverage: Pass
  - API contract: Pass
  - Code quality: Pass
  - Plan deviation: Pass
  - Verification trust: Pass

- 발견된 문제: 없음

- 다음 단계:
  - PASS: `complete.log` 작성 후 task 디렉터리를 `agent-task/archive/2026/05/02+yaml_validation/`로 이동한다.
