Skip to content

S10-2: tools 핸들러 물리 분할 — 5개 서브모듈, __init__ 1532→324줄#37

Merged
epruseal merged 2 commits into
mainfrom
refactor/s10-tools-split
Jul 6, 2026
Merged

S10-2: tools 핸들러 물리 분할 — 5개 서브모듈, __init__ 1532→324줄#37
epruseal merged 2 commits into
mainfrom
refactor/s10-tools-split

Conversation

@epruseal

@epruseal epruseal commented Jul 6, 2026

Copy link
Copy Markdown
Owner

청산 웨이브 2/2 (마지막 잔여 과제). Stage 7에서 보류했던 물리 분할을 실측 근거 확보 후 실행.

변경

  • 핸들러 16개 → tools/{graph,query,pack,schema,harness}.py 이동(@tool 데코레이션 유지), init.py 1532→324줄(공유 plumbing+재수출만)
  • 패치 생존 설계: _get_context·_context dict·락은 init 잔류(57곳 patch 타겟), 핸들러는 함수 스코프 late-import로 패키지 속성 참조 → mock.patch 리포인트 0곳(적대적 실증: 서브모듈 거주 핸들러 dispatch 시 패키지 패치가 mock called 확인)
  • @tool(order=N): 골든 TOOLS 순서가 모듈 간 인터리빙이라 import 순서로 재현 불가 → 명시 순서 kwarg(충돌 시 raise, 미지정 시 삽입순 폴백). TOOLS는 main과 바이트 동일(worktree 전수 diff)
  • _context.py_shared.py 리네임: 패키지 _context dict 속성과의 서브모듈 이름충돌(섀도잉 해저드) 해소 — import 후에도 dict 유지 실증

원장

1760 passed / 3 skipped / 0 failed, cov 91.38% (게이트 85), ruff clean. 시뮬레이션-CI 동일.

fable 검증 PASS

TOOLS·TOOL_SCHEMAS·WRITE_TOOLS main 바이트 대조, 핸들러 출력 동일, late-import 적대 실증, _legacy shim 무결, apps.api.main 스모크. 권고 3건(Available 목록 순서 main 정렬·order 충돌 가드·스테일 docstring) 반영 완료.

epruseal added 2 commits July 6, 2026 18:40
… + _context→_shared 리네임

- __init__.py 1532→324줄: 공유 plumbing(_get_context·_context dict·락 — 패치 57곳 타겟이라 불이동)+재수출만
- 핸들러는 함수 스코프 late-import로 패키지 속성 참조 → mock.patch('opencrab.mcp.tools.X') 전부 무리포인트 생존(실증)
- TOOLS 골든 순서가 모듈 간 인터리빙이라 @tool(order=N) 명시 kwarg 도입(미지정 시 삽입순 폴백 하위호환) — 바이트 일치 실증
- _context.py(서브모듈) → _shared.py: 패키지 _context dict 속성과의 이름 충돌(섀도잉 위험) 해소
@epruseal
epruseal merged commit 1146c54 into main Jul 6, 2026
1 check passed
@epruseal
epruseal deleted the refactor/s10-tools-split branch July 6, 2026 13:41
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