refactor(knowledge-graph): 变更 KG 构建单位与 Corpus chunk 计数规则为 parent chunk - #491
Merged
Merged
Conversation
- Repository 层新增 _parent_role_expr() 辅助函数,list_corpora_with_counts / get_corpus_with_counts 计数改为 chunk_role = 'parent'(非 hierarchical 语料库 fallback 到全量计数) - Dashboard 计数同步切换为 parent chunk 口径,含非 hierarchical fallback - API 层 build_knowledge_graph 端点在传递 chunks 给 build_graph 前过滤为 parent chunk only - Paper KG Pipeline enqueue_kg_build 在构建 chunks 前过滤 records 为 parent chunk 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
- Dashboard 计数改为复用 KnowledgeRepository.list_corpora_with_counts 按 corpus 粒度应用 parent/fallback 逻辑后再汇总,修复混合 hierarchical 与 non-hierarchical 语料库时 non-hierarchical chunks 被排除的计数错误 - 移除已废弃的 _top_level_role_expr 函数(生产代码无引用),同步更新测试覆盖为 _parent_role_expr 🤖 Generated with [Claude Code](https://github.com), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
ThreeFish-AI
added a commit
that referenced
this pull request
Jul 5, 2026
…-2026-4372 处置) (#1057) * fix(deps): ts-deepmerge 补丁地板至 8.0.0 修复 GHSA-87mf-gv2c-c62c (#481); 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com> * fix(negentropy): pydantic-settings 升 2.14.2 + joserfc>=1.6.7 补丁地板修复 #482/#488; 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com> * fix(cognizes): joserfc/msgpack/python-socketio/python-engineio 补丁地板修复 #483/#486/#487/#490/#491; 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com> * docs(perceives): ISSUE-092 增补 CVE-2026-4372 威胁模型;transformers 钉 4.x + dismiss #492(marker 5.x 不兼容实测); 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
chunk_role != 'child'(parent + leaf),对 hierarchical 语料库显示虚高(如 Harness Engineering 显示 156 而实际只有 20 个 parent chunk)核心变更
_parent_role_expr()辅助函数,list_corpora_with_counts/get_corpus_with_counts计数改为chunk_role = 'parent',非 hierarchical 语料库(无 parent chunk)fallback 到全量计数,保持兼容_top_level_role_expr() != 'child'切换为_parent_role_expr() == 'parent',同样含非 hierarchical fallbackbuild_knowledge_graph在传递 chunks 给build_graph前过滤为 parent chunk only(有 parent 时仅用 parent,否则保持全量)enqueue_kg_build在调用_records_to_chunks前过滤 records 为 parent chunk风险与回滚
chunk_role = 'parent'的 chunk,所有 fallback 路径已覆盖(parent_count = 0 时回退到全量计数 / 全量 chunks)git revert该提交即可,无数据库 schema 变更验证证据
影响范围
knowledge_count字段语义调整后 UI 显示自然适配_top_level_role_expr保留不删供 document chunks 页等继续使用Next Best Action