- platform/ → ont_platform/ rename
Python 내장 platform 모듈과 이름 충돌. numpy/scipy가 platform.machine() 호출 시
우리 패키지를 가져와 AttributeError. ont_platform으로 변경하고 pyproject.toml,
ont_platform/**, tests/** import 경로 모두 업데이트.
- ont_platform/config.py: lenient LLM builder 추가
LM Studio/vLLM 등 OpenAI-호환 로컬 서버가 임의 모델 식별자(예: deepseek-r1-distill-
qwen-7b)를 쓸 수 있도록 OntoCast의 OpenAIModel enum validation을 Pydantic
model_construct로 우회. ToolConfig() 생성 시 충돌을 막기 위해 LLM_MODEL_NAME을
잠시 비웠다가 lenient 인스턴스로 교체.
- ont_platform/api/deps.py: ToolBox 초기화를 asyncio.to_thread로 격리
LLMTool.create()가 내부에서 asyncio.run()을 부르는데 lifespan/테스트가 이미
async 컨텍스트라 이중 loop 충돌. 별도 스레드에서 sync 생성자 실행.
- 테스트 인프라 정비
* tests/integration/test_api_smoke.py: TestClient 구버전 starlette 호환을 위해
lifespan='off' 대신 app.router.lifespan_context = noop 패턴 적용.
* tests/unit/test_convert_document.py, test_select_ontology.py: ontocast.agent
__init__.py가 re-export한 함수가 서브모듈을 가리는 문제로 sys.modules에서
실제 모듈 객체 직접 추출.
* tests/e2e/conftest.py: .env 자동 로드 + provider별 skip 조건 (Ollama는
LLM_API_KEY 불필요).
* tests/e2e/test_phase0_full_pipeline.py: provider별 키 분기,
HDBSCAN 클러스터링이 동작하도록 fixture 페이로드 16문장으로 확장.
- vendored OntoCast 버그 수정 3건 (VENDORED_MODIFICATIONS.md 기록):
* agent/render_ontology.py: render_ontology_fresh()의 .format() 호출에 누락된
ontology_prefix 인자 추가 (Bootstrap 단계에서 KeyError: 'ontology_prefix').
* stategraph/node_factories.py: render_ontology/render_facts 노드의
state.model_copy(deep=True)로 budget_tracker가 deep-copy되어 root state의
BudgetTracker가 영원히 0인 채로 남던 버그 수정. 원본 인스턴스 공유로 변경.
- 문서 갱신
README.md (Phase 0.7 부분완료 + ont_platform 폴더 이름),
docs/phases/PHASE0_ACCEPTANCE_GATE.md (검증 이력 + Ollama/LM Studio 옵션),
.env.example (LM Studio/Ollama/OpenAI 세 옵션 명시).
검증
- unit + integration 26/26 통과.
- e2e (LM Studio + Qwen3-8B / DeepSeek-R1-Distill-Qwen-7B): 워크플로우 끝까지
실행 + 5번 LLM 호출 + LangGraph 전 노드 traceable 확인. 7-8B 로컬 모델은
strict structured output(Turtle RDF in JSON) 한계로 ontology/facts TTL 자동
생성 부분 성공. 클라우드 LLM 환경에서 재검증 필요.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
5.8 KiB
5.8 KiB
OntoCast Vendored Copy — 수정 내역
본 디렉터리는 OntoCast의 vendored copy다.
- 원본 저장소: https://github.com/growgraph/ontocast
- 원본 라이선스: Apache License 2.0 (
LICENSE파일 참조, 변경 금지) - vendored 시점 버전: 0.3.0
- vendored 시점: 2026-05-13
Apache 2.0 의무사항
본 vendored copy 내의 파일을 수정할 경우 Apache License 2.0 §4(b) 요구사항에 따라:
- 수정된 파일 상단에
# MODIFIED YYYY-MM-DD: <한 줄 설명>주석을 추가한다 - 본 문서(
VENDORED_MODIFICATIONS.md)에 수정 내역을 항목으로 기록한다 - 원본
LICENSE파일은 절대 삭제하거나 변경하지 않는다
수정 내역 (시간순)
2026-05-13 — vendored copy 생성
- 원본 https://github.com/growgraph/ontocast (v0.3.0)을
vendored/ontocast/로 복사 - 아직 어떠한 파일도 수정하지 않은 상태
2026-05-13 — Phase 0.3: convert_document.py 다중 파일 처리 확장
- 파일:
ontocast/agent/convert_document.py - 문제: 루프는 모든
state.files를 순회하지만state.set_text(result["text"])가 매 반복에서 덮어써 마지막 파일의 텍스트만 살아남았다("NB: processing only one file"주석으로 의도가 명시되어 있던 부분). - 수정: 텍스트를
texts: list[str]에 누적하고 파일이 2개 이상이면=== File: <name> ===경계 마커를 사이에 삽입해 단일 corpus로 합친다. 단일 파일 입력은 마커 없이 통과하여 기존 단일 파일 동작과 byte-identical. JSON envelope의ontology_user_instruction/facts_user_instruction/url은 first-wins (한 corpus는 하나의 instruction이라는 모델). 첫 unsupported 확장자에서 fail-fast하는 기존 동작 유지. - 회귀 테스트:
tests/unit/test_convert_document.py(7 케이스 — 단일 PDF / 단일 JSON / 다중 PDF / 다중 JSON first-wins / 미지원 확장자 / 빈 입력 / 혼합 PDF+JSON) - 근거: docs/통합설계서.md §5 Phase 0, OntoCast 분석 §13.1 / §21.1 (#4)
2026-05-14 — node_factories.py: BudgetTracker가 LLM 호출을 기록하지 못하던 버그 수정
- 파일:
ontocast/stategraph/node_factories.py - 문제:
make_render_ontology_node(line 91)와make_render_facts_node(line 256)에서 병렬 unit 처리 시base_state = state.model_copy(deep=True)로 root state를 deep-copy 한 뒤budget_tracker=base_state.budget_tracker를 child state(UnitOntologyState/UnitFactsState)에 전달했다. 그 결과 LLM이 add_usage()를 호출해도 복사본 인스턴스만 갱신되고 root state.budget_tracker는 영원히 0인 채로 남아 BudgetTracker가 LLM 호출 수, chars sent/received를 전혀 기록하지 못했다. e2e 실행 시 LM Studio 로그에 LLM 호출이 분명히 들어왔는데(token count 검증됨) workflow_state["budget_tracker"].calls_count == 0으로 응답되는 증상으로 확인됨. - 수정: 두 곳 모두
base_state.budget_tracker→state.budget_tracker로 변경.base_state = state.model_copy(deep=True)라인 자체가 budget_tracker 추출에만 쓰였으므로 함께 제거. Python int+= 1연산은 GIL 하에서 원자적이라 병렬 process_unit 간 race condition은 무시 가능한 수준. - 회귀 테스트: e2e (
tests/e2e/test_phase0_full_pipeline.py)에서budget.calls_count > 0검증. - 근거: docs/phases/PHASE0_ACCEPTANCE_GATE.md (Gate #3 통과를 위한 차단 이슈).
2026-05-14 — render_ontology.py: Bootstrap KeyError 수정
- 파일:
ontocast/agent/render_ontology.py - 문제:
vendored/ontocast/ontocast/prompt/render_ontology.py:44의general_ontology_instruction = f"""...{prefix_instruction}..."""이 f-string이라 모듈 로드 시점에prefix_instruction변수가 즉시 치환됨. 그 결과 최종 문자열에는prefix_instruction자체가 가진{ontology_prefix}placeholder만 남는다.render_ontology_update는 호출 시ontology_prefix=current.prefix도 함께 넘기지만render_ontology_fresh는 누락 → Bootstrap 단계에서KeyError: 'ontology_prefix'. - 수정:
render_ontology_fresh()의.format()호출에ontology_prefix=""를 추가. Bootstrap 시점에는 prefix가 아직 LLM에 의해 정의되지 않으므로 빈 문자열이 의미적으로 올바름. - 회귀 테스트: e2e (
tests/e2e/test_phase0_full_pipeline.py)에서 검증. - 근거: docs/phases/PHASE0_ACCEPTANCE_GATE.md (Gate #1 통과를 위한 차단 이슈).
2026-05-13 — Phase 0.2: select_ontology.py None-index 버그 수정
- 파일:
ontocast/agent/select_ontology.py - 문제: dynamic Pydantic 모델은
answer_index ∈ [1, num_ontologies + 1]을 강제하지만 코드는answer_index == 0을 "None"으로 처리. 0은 Pydantic 검증을 통과할 수 없어 dead code였으며, LLM이 None을 선택할 때마다(num_ontologies + 1반환) defensive branch로 빠져 WARNING 로그가 찍혔다. - 수정:
none_index = num_ontologies + 1분기 추가,answer_index == 0분기 제거. 파일 상단에MODIFIED 2026-05-13주석 추가. - 회귀 테스트:
tests/unit/test_select_ontology.py(4 케이스 — 빈 ontology / 정상 선택 / None 선택 / 범위 밖) - 근거: docs/통합설계서.md §5 Phase 0, OntoCast 분석 §13.1
우리 프로젝트에서의 사용 방식
vendored/ontocast/ontocast/패키지는 우리 코드(platform/)에서 import하여 사용한다- OntoCast의 코어 모듈(
stategraph/,agent/,onto/,tool/)은 수정 최소화 - API 레이어(
vendored/ontocast/ontocast/cli/serve.pyRobyn)는 사용하지 않고 우리가 FastAPI로 재작성한다 - OntoCast 자체의
pyproject.toml은 참고용이며, 의존성은 프로젝트 루트의pyproject.toml이 우선