Repository navigation
Conversation
This branch has not been deployed
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.
变更说明
普通成员即使命中知识库的共享管理范围,仍受管理员菜单、路由和 API 依赖限制,无法进入知识库维护文档。本 PR 复用现有 version 2 共享范围,让成员按授权访问知识库,并把文档编辑与整库管理分开。
feature。工程主张与 Owner
resource_permission.py拥有用户/部门/全局范围判断,knowledge_permissions.py与 HTTP 路由拥有操作授权。响应分别返回can_edit_documents和can_manage;前端按能力展示操作,后端最终裁决。KnowledgeFileRepository.upsert()拒绝跨库 ID 碰撞。HTTP、PostgreSQL、MinIO 原件/派生对象及 worker 最终状态是观察边界。database.js与文件表格、上传、搜索组件拥有当前身份/库的界面投影;切库、会话或授权失效后清理旧载荷,迟到响应不能覆盖新上下文。验证情况
本地验证使用基于上游 main 的独立工作树、全新 Compose 状态和合成数据,直接回读 schema 为 business 9 / knowledge 2。Embedding 使用本地确定性 HTTP stub;HTTP、JWT、PostgreSQL、MinIO、Milvus、解析和索引 worker 均为真实链路。
成员文档编辑与管理员操作边界
pytest test/integration/api/test_knowledge_router.py::test_delegated_knowledge_content_permissions -q,3 passed。编辑流程回读上传原件字节、parsed/indexed、正文、文件夹改名、移动及删除后列表。Passed。凭据投影保持隔离,持久配置与运行参数不变
knowledge/utils/security.py、响应序列化与MilvusGraphService。test_knowledge_content_delegation.py的read_projections_remove_nested_credentials参数化案例,12 passed,覆盖三出口和四身份;额外真实 HTTP 探针验证编辑者、读取者和管理者的九种出口,PG 配置读取前后保持不变。accessToken,并保留模型 token 预算及chunk_token_num。Passed。文档操作不能破坏外库原件或覆盖外库记录
KnowledgeFileRepository。pytest test/integration/api/test_knowledge_document_storage_isolation.py -q,4 passed;pytest test/integration/repositories/test_knowledge_file_upsert.py -q,2 passed。最终修复后的三组集成共 9 passed、0 skipped。Passed。前端能力展示与旧上下文隔离
pnpm run test:unit,445 passed,无失败/取消/跳过;Web lint/build 通过。真实浏览器验证普通编辑者与只读账号、同一成员切至只读库、文件夹上传模式、浅/深色及 900px 视口。Passed。通用回归、格式和工程契约
pytest test/unit -m 'not slow' --timeout=90 -q -p no:cacheprovider,2,551 passed;此集合执行在补充嵌套凭据案例前,最终受影响集合另为上述 170 passed,两者不相加。python scripts/verify_engineering_contracts.py、python -m unittest scripts.test_verify_engineering_contracts(63 tests)、21 个受影响 Python 文件 Ruff lint/format、Web lint/build、docs build、git diff --check全部通过。a-button属性,保持整库配置入口的权限断言;其他负向边界见各验收组。Passed。简化 / 删除验收
不涉及。
独立语义 Review
不继承开发上下文的全新 Reviewer 审查完整需求、上游完整 diff、权限/持久化/对象副作用、前端实际组件、公开文档与最终证据。发现并修复嵌套模型凭据投影问题,补充三出口负向案例及真实 HTTP/PG 回读。最终完整暂存树与合成截图审查后无未解决的 P1/P2。Review 结论不代替测试证据。
未验证范围与风险
Not run:真实模型质量、Dify/RAGFlow 等第三方知识库端到端、真实外部 OAuth 和生产部署。本地确定性 Embedding 验证权限/协议/索引链路,不能证明检索质量。Inspected:现有 CI 会覆盖 backend/Web unit 等 gate,但当前 system-tests 工作流没有选择上述三组知识库集成文件;本 PR 的 9 项集成证据来自独立本地真实拓扑。Not run:本 PR 的 GitHub CI 结果在创建后产生。os.O_DIRECTORY的后端测试;后端结果来自 Linux 容器。事故反馈
本 PR 处理成员文档维护功能缺口,未确认达到高影响生产事故门槛。评审发现的嵌套凭据边界以直接反例、响应 guard 和回归测试闭合。
界面变更
真实页面截图仅使用隔离环境中的合成账号、知识库与文档,不含客户数据或凭据。
普通编辑者可维护文档,整库配置/评估管理入口隐藏:
同一共享库对普通只读账号隐藏写操作:
普通成员的上传模式包含文件、文件夹、个人空间:
编辑成员切到只读库,深色 900px 页面保留可访问的只读操作与横向表格滚动:
关联事项
Closes #1094
补充说明
不新增权限枚举、数据库 schema 或依赖。复用 version 2 的 read/manage 范围,并在角色与操作边界区分文档编辑和整库管理。客户端需使用
can_edit_documents判断文档维护能力,can_manage表达整库管理能力。