diff --git a/docs/architecture/PHASE-Q-AUDIT.md b/docs/architecture/PHASE-Q-AUDIT.md index 28d1c5d..e3fe14b 100644 --- a/docs/architecture/PHASE-Q-AUDIT.md +++ b/docs/architecture/PHASE-Q-AUDIT.md @@ -619,7 +619,72 @@ F3. (제거) — `calculate_font_hierarchy` / `calculate_dynamic_ratio` 는 **Ar > > **Archive Candidate 자산은 Kei 입력 / page_structure / role_text_lengths 의존 자산으로 한정**: `calculate_container_specs`, `build_containers_type_b`, `calculate_font_hierarchy`, `calculate_dynamic_ratio`. Phase Z normal path 에 입력 source 없음. §3 검토 대상 외. -### 2.6 `content_editor.py` — *후속 turn* +### 2.6 `content_editor.py` + +#### 역할 + +Phase Q normal pipeline 의 3 단계 — Kei 텍스트 편집자. `layout_concept` 의 모든 page / block 의 slot 을 Kei API 직접 호출로 채움. fallback 없음 (Kei API 가 응답할 때까지 무한 retry, `RETRY_INTERVAL=10s`). 475 lines, 4 함수 + 1 상수 (`EDITOR_PROMPT`). + +핵심 함수: + +- `fill_content` — main entry. async. 모든 page / block 의 slot fill. retry max 3. +- `_call_kei_editor_with_retry` — Kei API 직접 호출 (`httpx` + SSE streaming). 무한 retry. +- `fill_candidates` — Phase P (다후보) — 1 topic 의 3 후보 blocks 한꺼번에 Kei fill. +- `_parse_json` — Kei response JSON 추출 (마크다운 prefix 제거 + 3 pattern 정규식). +- `EDITOR_PROMPT` (상수) — Kei persona system prompt (도메인 전문가 텍스트 편집자). + +Phase Q-3 글자수 예산 input (`_char_budget`) 은 §2.5 의 `calculate_char_budget` 출력과 연결된다. 다만 여기서는 Kei AI 호출의 hard constraint 로 사용되므로, Phase Z normal path 의 Reference 판단 (§2.5 SoT) 과는 분리한다. + +#### 관련 §7-B 항목 + +| §7-B | 직간접 | 영향 | +|---|---|---| +| **B-1** Zone-section assignment override (§1 매핑) | (부정확) | §1 lens 표에 `content_editor.py` 가 B-1 후보 파일로 listed 단 *실제 매핑 X* — zone-section override 는 `pipeline.py` / composition planner 영역. content_editor 는 *block 안 slot 채우기*. §1 정정 별 axis 후보 (G2) | +| **B-2** Edited HTML → MDX 역변환 (§1 매핑) | (부정확) | §1 표 매핑 단 *forward direction* (text → slot fill) 인 content_editor 는 *역변환* 과 반대. 글벗 `html_to_slide_mdx` 가 B-2 main. §1 정정 별 axis 후보 (G2) | + +#### 현재 Phase Z 와 겹치는 영역 + +| Phase Q `content_editor` | Phase Z (현재) | 비교 | +|---|---|---| +| `fill_content` (Kei AI 전체 slot fill) | (Phase Z normal path 미존재 — AI 격리 invariant) | Phase Z = Step 11 `slot_mapping` 의 *결정론적 mapper* (frame contract slot ↔ content_object). AI 호출 X. **abstraction 완전 다름** | +| `_call_kei_editor_with_retry` (Kei API infra) | (Phase Z normal path 미존재) | Phase Z 본체 AI 호출 X. Step 12 light_edit/restructure 는 *AI repair fallback path* + 별 인프라. **본 audit 범위 외 (L3)** | +| `fill_candidates` (Phase P 다후보) | (Phase P 폐기) | Phase P era artifact. Phase Z 단일 path master | +| `_parse_json` (response parsing) | (Phase Z normal path 미존재) | AI 호출 없으므로 parsing 도 없음 | +| `EDITOR_PROMPT` | (Phase Z normal path 미존재) | Kei persona 자체 = Phase Z 본체 외 | + +#### 재사용 가능성 + +| 자산 | 분류 | 근거 | +|---|---|---| +| `fill_content` | **Archive Candidate** | Kei AI 슬롯 fill flow. Phase Z normal path 의 Salvage / Reference 대상은 아님 | +| `_call_kei_editor_with_retry` | **Archive Candidate** | Kei API 직접 호출 인프라. Phase Z normal path 의 Salvage / Reference 대상은 아님. AI repair fallback 은 본 audit 범위 밖이며, 별도 axis 활성 시 새 기준으로 재검토 | +| `fill_candidates` | **Archive Candidate** | Phase P 다후보 era + Kei AI 의존 | +| `_parse_json` | **Archive Candidate** | 결정론적 utility 단 Phase Z normal path 활성 axis 부재. AI response parsing 영역은 본 audit 밖, 별도 axis 활성 시 새 기준으로 재검토 | +| `EDITOR_PROMPT` (상수) | **Archive Candidate** | Kei persona prompt — Phase Z 본체 외 | + +#### audit 판정 + +**Archive Candidate (module-level)**. + +- 이유: Kei AI direct slot-fill flow, Phase Z normal path 와 abstraction 불일치 (AI 격리 invariant + §0-B Audit 범위 lock 따름) +- §3 Salvage Plan 대상: **없음** +- 별도 surface: + - §1 audit lens 표의 B-1 / B-2 후보 파일 매핑 정정 필요 (G2 별 axis) + - AI repair fallback 의 infrastructure 참고 (`httpx` + SSE + retry + JSON parse) 여부는 본 audit 밖, 별도 axis 활성 시 재검토 (G3 별 axis) + +#### 후속 참고 사항 (본 audit 밖 surface) + +G1. (제거) — `content_editor.py` 모든 자산 Archive Candidate. Phase Z normal path 의 Salvage / Reference 대상은 아님. §3 검토 대상 외. + +G2. (별 axis 후보, 본 audit 외) — §1 audit lens 표의 B-1 / B-2 column 에 `content_editor.py` 매핑 부정확. content_editor 는 B-1 zone-section override / B-2 HTML→MDX 역변환 에 직접 관여 X. §1 정정 별 axis 검토. + +G3. (별 axis 후보, 본 audit 외) — AI repair fallback (Phase Z step12 light_edit/restructure) 설계 axis 활성 시, content_editor 의 *infrastructure pattern* (`httpx` + SSE streaming + retry + JSON parse) 이 reference 가능. 단 §0-B Audit 범위 lock (L3) 따라 *별 axis 활성 시 새 기준으로 재검토* — 본 audit 에서는 평가 X. + +#### Salvage Plan 검토 대상 dual-write 기준 (§3 에서 재확정) + +**없음** — 모든 자산 Archive Candidate. §3 검토 대상 외. + +> ⚠ **본 §2.6 audit 판정은 Phase Z normal path 기준의 후보 분류이며, `content_editor.py` 자산은 현재 §3 Salvage Plan 대상 외로 둔다.** §0-A 의 10 원칙 + §0-0 의 분류 기준 + §0-B Audit 범위 lock + AI 격리 invariant 모두 따름. **AI repair fallback 의 평가 여부는 본 audit 밖 — 별도 axis 활성 시 새 기준으로 재검토**. ### 2.7 `content_verifier.py` — *후속 turn* @@ -706,7 +771,7 @@ audit 결과 → 어느 항목이: | 2026-05-11 | **audit wording + AI isolation 재분류 pass** | 완료 — §0-0 자산 분류 기준 추가 (Salvage / Reference Only / Archive Candidate) + AI 격리 invariant 명시 + audit 판정 ≠ 적용 결정 명시. §2.1 / §2.2 / §2.3 / §2.4 / §2.5 모두 정정: "Migrate / Migrate 강 후보 / 적극 통합 / 진짜 fix / 결정" 표현 제거. Kei AI 흐름 의존 자산 (`map_topics_to_sections`, `format_measurement_for_kei`, `analyze_enhancements` V-7~V-10 / `build_escalation_report`, `calculate_container_specs` / `build_containers_type_b` / `calculate_font_hierarchy` / `calculate_dynamic_ratio` / `calculate_design_budget` / `calculate_char_budget` / `calculate_trim_chars`, `measure_candidate_block`, `detect_component_popups`) 을 모두 **Archive Candidate** 로 재분류. Salvage Candidate 는 8 개 자산 (`normalize_mdx_content`, `extract_major_sections`, `extract_conclusion_text`, `_MEASURE_SCRIPT` JS extension, `capture_slide_screenshot`, `redistribute`, `compute_glue_css_overrides`+`calculate_glue_absorption`, `find_fitting_font_size`) — 모두 §3 검토 후보 *[후속 갱신: 2-c hygiene fix 2 의 F-3 함수별 재분류 (2026-05-11) 에 따라 `calculate_design_budget` / `calculate_char_budget` / `calculate_budgets_for_candidates` / `calculate_trim_chars` 는 Reference Only 로 재분류됨. §2.5 SoT 참조]* | | 2026-05-11 | 정정 pass 2 계획 확정 | 대기 — B-1~B-5 결정 적용. sub-axis a~g 로 진행. 실행은 다음 turn | | 2026-05-11 | 정정 pass 2 본체 실행 (2-c hygiene fix 2 + 2-d / 2-e / 2-f / 2-g) | 완료 — L1~L4 boundary lock 반영. §0-B Audit 범위 lock 추가, §2.5 F-3 함수별 재분류 반영 (`calculate_design_budget` / `calculate_char_budget` / `calculate_budgets_for_candidates` / `calculate_trim_chars` → Reference Only), §3 / §4 legacy 용어 정리, §5-1 인라인 재분류 태그 5 entry append, 13 pattern context-aware grep 검증 수행. 산출 추가: `PHASE-Q-AUDIT-PASS-2-EXECUTION-PLAN.md`, `memory/feedback_scope_qualified_verification.md` | -| (next) | §2.6 content_editor.py audit | (대기 — 정정 pass 2 후 새 기준으로) | +| 2026-05-12 | §2.6 content_editor.py audit | 완료 — Archive Candidate (module-level). Kei AI direct slot-fill flow. §3 검토 대상 외. 별도 surface: §1 B-1/B-2 매핑 부정확 (G2 별 axis), AI repair fallback infra reference 여부 별 axis (G3) | | ... | §2.10 까지 1 모듈씩 | (대기) | | (last) | §2.11 pipeline.py / pipeline_context.py | (대기) | | (then) | §3 Salvage Plan | (대기) |