feat: Workflow Knowledge Collection 런타임 라우팅 연결 - #400
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dcb4428076
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| WorkflowService.validate_knowledge_references( | ||
| db, | ||
| request, | ||
| user_id=user_id, | ||
| organization_id=workflow.organization_id, |
There was a problem hiding this comment.
지식 참조가 없을 때는 조직 UUID 검증을 건너뛰세요
이 새 검증 호출은 Knowledge 참조 존재 여부와 무관하게 모든 draft 저장에 실행되는데, workflows.organization_id는 아직 nullable이고 legacy app/workflow 보정 경로도 남아 있습니다. 그런 legacy workflow에서 지식 참조가 전혀 없는 그래프를 저장해도 validate_knowledge_references()가 uuid.UUID(str(None))를 수행해 422로 막히므로, 먼저 그래프의 Knowledge 참조를 파싱/집계한 뒤 참조가 없으면 반환하거나 기존 fallback으로 organization scope를 보정해야 합니다.
Useful? React with 👍 / 👎.
| .filter( | ||
| KnowledgeBase.id.in_(direct_ids), | ||
| KnowledgeBase.organization_id == self.organization_id, | ||
| KnowledgeBase.lifecycle_state == "active", |
There was a problem hiding this comment.
source_deleted KB를 저장 단계에서도 제외하세요
source_deleted KB가 과거 ready chunk/version을 보존한 경우 이 loader와 _retrieval_ready_ids()는 lifecycle만 확인하므로 direct KB 참조가 저장/배포 검증을 통과합니다. 하지만 이번 변경의 runtime candidate adapter는 sync_state == "source_deleted"를 후보에서 제외하므로, preflight는 통과했는데 배포된 RAG 노드는 실행 시 후보 없음으로 안전 응답을 반환할 수 있습니다. write/preflight readiness 경계에도 동일한 sync_state != "source_deleted" 조건을 적용해야 합니다.
Useful? React with 👍 / 👎.
| else self._resolve_runtime_knowledge_candidates() | ||
| ) | ||
| candidate_summary = self._knowledge_candidate_trace_summary(resolution) | ||
| kb_ids = [str(candidate.knowledge_base_id) for candidate in resolution.candidates] |
There was a problem hiding this comment.
Collection 후보 ID를 trace/result에 노출하지 마세요
Collection을 선택한 LLM 노드에서는 resolver가 동적으로 찾은 child KB들이 여기서 provenance 없이 평탄한 KB id 목록이 되고, 이후 _knowledge_trace_metadata()와 _record_rag_retrieve_audit()가 이 id와 chunk/document id를 metadata.knowledge_search, trace payload, audit metadata에 그대로 씁니다. Collection membership을 graph에 materialize하지 않고 count bucket만 남기는 계약과 달리 public/실행 결과에서 숨겨야 할 child identity가 드러날 수 있으므로, collection 유래 candidate는 provenance를 유지해 result/trace/audit에서는 id 대신 bucket/route summary로 redaction해야 합니다.
Useful? React with 👍 / 👎.
| KnowledgeCollection.created_at.desc(), | ||
| KnowledgeCollection.id.asc(), | ||
| ) | ||
| .limit(MAX_LLM_SELECTABLE_COLLECTION_SCAN) |
There was a problem hiding this comment.
권한 필터 전에 Collection 목록을 자르지 마세요
여기서 active Collection을 최신순 500개로 먼저 자른 뒤에 bulk_evaluate_collection_action(..., "route")를 적용하므로, 조직에 active Collection이 500개를 넘고 사용자가 route 권한을 가진 Collection이 그 뒤에 있으면 LLM picker가 빈 목록을 반환하거나 기존 선택을 unavailable로 표시합니다. route 권한이 있는 후보 기준으로 제한하거나 pagination/search를 붙여야 권한 있는 Collection을 안정적으로 선택할 수 있습니다.
Useful? React with 👍 / 👎.
dcb4428 to
538032a
Compare
|
@codex review |
cb42515 to
56cb023
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 56cb023719
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| KnowledgeBase.id.in_(direct_ids), | ||
| KnowledgeBase.organization_id == self.organization_id, | ||
| KnowledgeBase.lifecycle_state == "active", | ||
| KnowledgeBase.sync_state != "source_deleted", |
There was a problem hiding this comment.
이 새 source_deleted 제외 조건은 저장/배포 시 해당 KB 참조를 403으로 막지만, Builder가 쓰는 /knowledge/llm-selectable 후보 조회는 여전히 lifecycle_state == "active"와 completed chunk만 확인해서 source-deleted KB가 목록에 남을 수 있습니다. 외부 source 삭제 후 chunk가 남아 있는 KB를 사용자가 picker에서 선택하면 UI가 허용한 선택을 저장할 때 바로 실패하므로, 같은 sync_state != "source_deleted" 필터를 selectable 후보에도 적용해야 합니다.
Useful? React with 👍 / 👎.
| .filter( | ||
| KnowledgeCollection.id.in_(collection_ids), | ||
| KnowledgeCollection.organization_id == self.organization_id, | ||
| KnowledgeCollection.lifecycle_state == "active", |
There was a problem hiding this comment.
source-deleted Collection을 저장 시 제외하세요
source-backed Collection이 삭제되어 sync_state='source_deleted'가 되었지만 lifecycle이 아직 active인 경우, 이 조회는 계속 Collection을 로드해서 route 권한만 있으면 workflow 저장/배포 검증을 통과시킵니다. 그러면 stale Collection 참조가 runtime 후보 해석까지 남을 수 있으므로, Collection의 sync eligibility도 검증하도록 KnowledgeCollection.sync_state != 'source_deleted' 조건을 같은 경계에 추가해야 합니다.
Useful? React with 👍 / 👎.
| kbs_by_id = self.repository.get_active_knowledge_bases( | ||
| kb_ids, | ||
| self.organization_id, | ||
| ) |
There was a problem hiding this comment.
preflight에서도 KB readiness를 검증하세요
여기서는 direct KB를 active 여부로만 평가해서, public Collection에 연결된 active KB가 아직 retrieval-visible chunk/version이 없는 경우에도 preflight가 통과할 수 있습니다. 하지만 실제 배포 생성은 앞단의 validate_knowledge_references에서 같은 KB를 retrieval-ready가 아니라고 403으로 거부하므로, 사용자는 배포 전 검사는 통과했는데 곧바로 배포가 실패하는 흐름을 보게 됩니다; preflight repository/result에도 save-time과 같은 readiness 경계를 반영해야 합니다.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex 리뷰를 검토한 결과, 최신 P2 3건이 모두 타당하여 인접 우회 경로까지 함께 보완했습니다. 조치 내용
근본 원인은 picker, save, preflight, runtime이 적격성 조건을 개별 구현하면서 lifecycle, sync state, retrieval readiness 일부가 경로별로 누락된 policy drift였습니다. 공통 predicate와 교차 경계 테스트를 추가해 재발 가능성을 낮췄습니다. 검증
커밋
두 커밋 모두 |
286416d to
fe03d03
Compare
There was a problem hiding this comment.
💡 Codex Review
mbased/apps/workflow_engine/adapters/knowledge_runtime_candidates.py
Lines 666 to 668 in 286416d
Preflight는 source-managed Collection을 source_public_exposure_required로 차단하도록 추가됐지만, 실제 런타임 resolver는 여기서 safe_metadata.visibility == "public"만 확인해 allowed_collection_ids에 포함합니다. 그래서 public/chatbot/webhook 같은 anonymous_public 실행에서 기존 public Collection이 source-managed가 되거나 source-managed Collection이 public 상태이면, 배포 전 검사와 달리 그 Collection의 manual child KB가 검색 후보로 사용되어 source public exposure 경계를 우회할 수 있습니다; runtime에서도 source_identity_id/public exposure approval을 fail-closed로 확인해야 합니다.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
리뷰에서 지적된 anonymous source-managed Collection 우회 경로를 커밋 54405aae에서 보완했습니다. 조치 내용:
검증 결과:
|
|
PostgreSQL CI 실패를 커밋 4344d98e에서 수정했습니다. 원인:
조치:
검증:
|
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
변경 사항
knowledgeBases와 함께 사용할 수 있는knowledgeCollections참조를 추가하고, UUID 형식·객체 구조·목록별 최대 20개 제한을 Shared 계약으로 검증합니다.route권한만 반영하는 최소 선택 목록 API를 추가했습니다. 모든 편집 가능 그래프 저장 경로에서 직접 KBuse와 Collectionroute권한을 서버가 다시 검증하며, 관리용 응답이나 저장된 표시값을 권한 근거로 사용하지 않습니다.관련 이슈
Linear: MBA-233
변경 유형
테스트
로컬에서 테스트 완료
기존 테스트 통과 확인
Workflow Engine 전체:
606 passedGateway 관련 범위:
158 passedShared 전체:
714 passed, 31 skippedRoot 영향 범위:
169 passed, 1 skippedClient 전체 Vitest: 통과
Client lint: 오류 0건, 기존 warning 225건
Client production build: 통과
git diff --check origin/dev...HEAD: 통과로컬 PostgreSQL 연결이 필요한 일부 검증과 실제 배포 환경의 Worker-first canary/drain 증거는 배포 전 운영 게이트로 남아 있습니다.
스크린샷 (UI 변경 시)
LLM 노드 Knowledge 선택 패널 UI가 변경되었습니다. 컴포넌트 테스트와 production build로 검증했으며 별도 스크린샷은 첨부하지 않았습니다.