Skip to content

refactor: reverse-sync patch_builder.py 구조 분해 (R4+R7+R8)#855

Merged
jk-kim0 merged 9 commits intomainfrom
refactor/reverse-sync
Feb 26, 2026
Merged

refactor: reverse-sync patch_builder.py 구조 분해 (R4+R7+R8)#855
jk-kim0 merged 9 commits intomainfrom
refactor/reverse-sync

Conversation

@jk-kim0
Copy link
Contributor

@jk-kim0 jk-kim0 commented Feb 25, 2026

Summary

`patch_builder.py` (719줄)를 책임 단위로 분해하여 유지보수성을 개선합니다. 동작 변경 없음 — 함수 이동 + import 변경만 수행합니다.

변경 내용

구분 내용
R8 `NON_CONTENT_TYPES` 상수를 `block_diff.py`로 통합 (6곳 → 1곳 정의)
R7 `xhtml_patcher.py`의 `_iter_block_children()` 중복 제거 (`mapping_recorder.py` import)
R4 `patch_builder.py` (719줄) → 3개 모듈 분리

신규 모듈

모듈 추출 내용
`inline_detector.py` 인라인 포맷 변경 감지 6개 함수 + regex 4개
`list_patcher.py` 리스트 블록 패치 4개 함수 (`_resolve_child_mapping`, `split_list_items`, `extract_list_marker_prefix`, `build_list_item_patches`)
`table_patcher.py` 테이블 블록 패치 4개 함수 (`is_markdown_table`, `split_table_rows`, `normalize_table_row`, `build_table_row_patches`)

`patch_builder.py` 잔여: 342줄 (719줄 → 342줄, 52% 감소)

Rebase 시 main 변경 사항 반영 (#852)

main 브랜치 rebase 과정에서 #852의 인라인 감지 정밀화 변경을 `inline_detector.py`에 통합했습니다.

  • `has_inline_marker_added` (type 추가/제거만 감지) → `has_inline_boundary_change`로 교체
    • 기존: 마커 type 목록 변경만 감지
    • 변경: 마커 type 변경 또는 연속된 마커 사이 텍스트 변경(경계 이동)을 감지
  • `list_patcher.py`의 `build_list_item_patches`도 동일하게 갱신

Test plan

  • 매 Task 완료 후 전체 테스트 실행
  • main rebase 후 최종 `python3 -m pytest tests/ -q --ignore=tests/test_unused_attachments.py` → 735 passed (main 신규 테스트 5개 포함)

🤖 Generated with Claude Code

@jk-kim0 jk-kim0 self-assigned this Feb 26, 2026
jk-kim0 and others added 9 commits February 26, 2026 12:50
- analysis-reverse-sync-refactoring.md: 최근 버그 패턴 분류, 디자인 결함 분석, 리팩토링 대상 R1~R9 도출
- r4-patch-builder-decompose-design.md: patch_builder.py 719줄 구조 분해 설계

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
list_patcher.py 추출 후 patch_builder.py에 잔존한
convert_inline, split_list_items, extract_list_marker_prefix import 제거.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jk-kim0 jk-kim0 force-pushed the refactor/reverse-sync branch from c5527b7 to 2d0db60 Compare February 26, 2026 03:55
@vercel
Copy link

vercel bot commented Feb 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
querypie-docs Ready Ready Preview, Comment Feb 26, 2026 3:59am

Request Review

@jk-kim0 jk-kim0 merged commit 16a7230 into main Feb 26, 2026
7 checks passed
@jk-kim0 jk-kim0 deleted the refactor/reverse-sync branch February 26, 2026 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant