Skip to content

Stage 4: GraphStore Protocol + find_neighbors _expand — Neo4j 확장 7종·소비자 스니핑 제거 (cov 86%)#28

Merged
epruseal merged 5 commits into
mainfrom
refactor/s4-protocol
Jul 5, 2026
Merged

Stage 4: GraphStore Protocol + find_neighbors _expand — Neo4j 확장 7종·소비자 스니핑 제거 (cov 86%)#28
epruseal merged 5 commits into
mainfrom
refactor/s4-protocol

Conversation

@epruseal

@epruseal epruseal commented Jul 5, 2026

Copy link
Copy Markdown
Owner

프로그램 Stage 4/9. 그래프 스토어 인터페이스 균일화 + find_neighbors 중복 제거.

R6 — find_neighbors _expand 추출 (순수 리팩)

local(151→59줄)·pg의 out/in 방향 중복 블록을 _expand(direction) 하나로 통합. pg의 레벨 단위 배치 prefetch(_batch_frontier_edges/_batch_node_props_multi) 보존. 백엔드 파라미터라이즈 계약 테스트(test_find_neighbors_contract.py)가 안전망.

R5 — GraphStore Protocol + Neo4j 균일화

  • _graph_protocol.py: GraphStore(base 13종) + GraphStoreExtended(7종) @runtime_checkable Protocol
  • Neo4jStore에 확장 7종 구현(get_node_by_id·list_packs·find_by_relations·export_nodes/edges·upsert_*_batch) — 기존 소비자에 흩어져 있던 Cypher를 재사용해 local/pg와 output parity
  • 소비자 hasattr/isinstance 스니핑 제거: content_pack_list·ontology_get_node·impact.analyse/lever_simulate·neo4j_export(죽은 _node_query 등 3헬퍼 삭제)

부수 동작 변화 (PR 명기)

  • ontology_list_edges: 4백엔드 wide-shape 통일(Neo4j만 narrow였던 것 해소 — Stage 1 판단보류 항목). Neo4j 모드 MCP 출력 shape 변화이나, 프로덕션은 local 모드라 실사용 영향 없음. narrow run_cypher 폴백(테스트 없던 방치 경로) 삭제.
  • ontology_list_nodes(Neo4j): mongo 폴백 → 그래프 네이티브 export_nodes. add_node가 graph+doc 양쪽 fan-out이라 정상 경로 동일 집합.

남긴 스니핑 (문서화)

  • query.py:812 keyword_search isinstance: Protocol에 keyword_search 부재 → Stage 8 이관(주석)

원장

시점 passed skipped cov
Stage 3 1378 3 85%
Stage 4 1504 3 86% (래칫 82)

fable 검증

조건부 PASS → 후속 3건 반영: F1(list_edges 스니핑이 R5로 무력화된 것을 wide 통일로 명시화, red-first), F2(keyword_search 예외 주석), F3(죽은 코드). R6 순수 추출·배치 보존, R5 Cypher/shape parity, ontology_list_nodes 등가성 하드증거 확인. 시뮬레이션-CI 1504/0 failed.

프로세스

전 서브에이전트에 git 상태변경 명령 전면 금지(Stage 3 reset 사고 재발 방지) — 무사고.

epruseal added 5 commits July 6, 2026 01:21
…hbors·Protocol 계약 테스트

- _graph_protocol.py: base 13종 + extended 7종(get_node_by_id 포함 — Neo4j 미구현 확인) 2-Protocol 분리
- test_find_neighbors_contract.py: R6 특성화 51건(3백엔드, self-loop 백엔드차 pin)
- test_graph_protocol_contract.py: R5 계약, Neo4j extended 8건 xfail(strict)=D3 대상
- Neo4j extended 7종 계약을 정상/오류/엣지 실어서션으로 교체(존재확인→동작검증)
- FakeNeo4jStore가 export_nodes/edges 직접 호출에 대응하도록 갱신
…핑 제거

- R6: local(151→59줄)·pg find_neighbors의 out/in 중복 → _expand(direction), pg 배치 prefetch 보존
- R5: Neo4jStore에 get_node_by_id·list_packs·find_by_relations·export_nodes/edges·upsert_*_batch 7종 구현(기존 흩어진 Cypher 재사용으로 output parity)
- 소비자 hasattr/isinstance 스니핑 제거: content_pack_list·ontology_get_node·impact.analyse/lever_simulate·neo4j_export(죽은 _node_query 등 3헬퍼 삭제)
- 남김(STOP&report): list_edges wide/narrow shape 비대칭(Stage 6 정규화 대상), query.py:697 shim(test-only 페이크 시그니처 가드 — 실제로 R5 무관, Stage 8 테스트 정리 시 제거)
- ontology_list_edges: R5로 Neo4j가 export_edges 획득 → narrow run_cypher 폴백 삭제, 4백엔드 wide-shape 통일(Stage 1 판단보류 비대칭 해소), 예외 시 실제 메시지 반환
- query.py:812 keyword_search isinstance 분기: Protocol 미포함 사유 주석(Stage 8 이관)
- ontology_list_nodes else 내 도달불가 if pack_id 필터 제거
@epruseal
epruseal merged commit d5bef37 into main Jul 5, 2026
1 check passed
@epruseal
epruseal deleted the refactor/s4-protocol branch July 5, 2026 16:57
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