Repository navigation
Conversation
实现四区域检测器配置、预设档、运行时热更新与安全策略设置页。\n配置修改受 RBAC 保护并写入审计链,judge 密钥不回传前端。
There was a problem hiding this comment.
Hi @waynejoon! 👋
Your private repo does not have access to Sourcery.
Please upgrade to continue using Sourcery ✨
There was a problem hiding this comment.
Pull request overview
本 PR 在 Fulcrum 的安全管线之上引入“按区域(detector zones)配置检测器 + 分级预设(profile) + 持久化与热更新”的完整闭环,并在控制台新增“系统设置-安全策略”页面与对应的 /admin/security-config 管理 API,实现运行中可审计、可回滚的安全配置变更。
Changes:
- 引入四区域检测器配置契约(
gateway_input/gateway_output/tool_return/assistant_intent),兼容旧的扁平detectors列表,并让管线按区域执行检测与审计摘要落盘。 - 新增分级安全配置模型与存储(profile + zone overrides + judge 配置),并提供 RBAC 保护的
GET/PUT /admin/security-config、候选预构建校验、原子落盘、运行态热替换与审计留痕。 - 控制台新增安全策略设置面板(中英文文案、只读展示与可编辑保存),并补齐测试与 OpenAPI 文档输出。
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_walking_skeleton.py | 为集成测试注入 security_config_path,覆盖新配置落盘入口。 |
| tests/test_security_config.py | 覆盖 profile 展开、覆盖规则、air-gapped loopback 校验、API key 掩码、路由 RBAC/回滚/审计等核心行为。 |
| tests/test_detector_zone_config.py | 覆盖 detectors 扁平/分区 schema 兼容、构建期校验、按区调度与审计摘要契约。 |
| src/fulcrum/core/pipeline.py | 增加 detector zones 支持、按区检测调度、intent 参数复扫、审计记录 detector_config 摘要与 revision。 |
| src/fulcrum/core/domain/enums.py | 新增审计事件类型 SECURITY_CONFIG_UPDATED。 |
| src/fulcrum/config/settings.py | 新增 security_config_path 配置项用于安全配置持久化。 |
| src/fulcrum/config/loader.py | 增加 DETECTOR_ZONES 与 normalize_detector_zones,规范化并校验 detectors 配置。 |
| src/fulcrum/config/fulcrum.yml | 将 detectors 从扁平列表升级为四区显式同配(保持旧行为),为后续按区调整打基础。 |
| src/fulcrum/config/init.py | 导出 DETECTOR_ZONES/normalize_detector_zones 供装配与测试复用。 |
| src/fulcrum/app.py | build_pipeline 强制通过 normalize 校验并构建 zone 映射;create_app 注入 SecurityConfigStore 并按配置装配管线。 |
| src/fulcrum/adapters/security_config.py | 新增安全配置模型、预设档、judge loopback 校验、公开 DTO 掩码与 JSON 原子存储。 |
| src/fulcrum/adapters/api/security_config_routes.py | 新增 /admin/security-config 路由:RBAC、候选预构建、落盘、运行态热替换、审计与失败回滚。 |
| src/fulcrum/adapters/api/schemas/admin.py | 增加 SecurityConfig 读写 DTO(密钥只写不回)。 |
| src/fulcrum/adapters/api/app.py | build_api 增加可选注入 security_store/capability_config/pipeline_factory,并注册 security-config routes。 |
| docs/plan/15-开放PR盘点与后续实施计划.md | 新增计划文档,盘点开放 PR 与后续实施建议/边界。 |
| docs/api/openapi.json | 更新 OpenAPI 输出(版本号与新增/调整的 schema/paths)。 |
| console/src/lib/i18n/locales/zh/settings.ts | 增加安全策略设置页中文文案 key。 |
| console/src/lib/i18n/locales/en/settings.ts | 增加安全策略设置页英文文案 key。 |
| console/src/lib/admin/index.ts | 增加 security-config 的 TS 类型与 API 调用封装。 |
| console/src/features/settings/settings-page.tsx | 设置页新增“安全策略”分类并挂载面板。 |
| console/src/features/settings/security-config-panel.tsx | 新增安全策略面板:profile、四区检测器开关、judge 配置与保存。 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # 只记录 judge 是否配置与是否满足隔离档,不记录 endpoint 或密钥。 | ||
| "judge_configured": bool(next_config.judge.api_key), | ||
| "air_gapped": next_config.profile == "air_gapped", | ||
| }, |
| <SettingRow label={t('settings.security.profile.label')} hint={t('settings.security.profile.hint')}> | ||
| <Segmented | ||
| value={draft.profile} | ||
| onValueChange={(value) => save({ ...toWrite(draft), profile: value as SecurityProfile, zone_overrides: {} })} |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
补充 PR #116 分级安全配置与控制台设置的进度看板记录。
安全配置文件无法读取或校验时拒绝启动,避免运行时静默回退到较低防护档位。
评审结论:需 rebase 到最新 dev本 PR 分叉自
当前 dev 已到 本地实测(基于旧 dev 的数字)
行动建议请 rebase 到最新 dev ( 检测类 PR(#115/#111/#113) 需特别关注:rebase 后可能与 #124 的新规则产生语义冲突(都在扩充检测面),需实测确认召回率叠加效果 ≥ 98.2%。 工程类 PR(#116/#121/#123/#120/#109) 风险较低,但也需验证 pytest 全绿且 eval 逐位不变。 |
FPSZ
left a comment
There was a problem hiding this comment.
评审结论:请求修改\n\n1. 必须 rebase 到最新 dev=0a877d7;当前 PR 分支名为 dev 且状态 DIRTY,无法作为可复现的独立变更审查。\n2. 分级配置会影响四区检测器、Judge 端点、热替换、RBAC 和审计,需在最新基线上补跑配置回滚、审计失败回滚、未知检测器拒绝、密钥不回显和并发更新测试。\n3. 请提供最新代码与评测结果后再复审,当前不批准。
入库副本停在 version 0.0.0 / 32 路径,当前应用已是 0.5.0 / 45 路径 —— 助手聊天、 流式、确认、撤销、审批、模型配置、事件处置、团队成员等整批端点在契约里查不到 (docs/status/03 §4.1 已登记)。重新导出补齐。 同时补一条门禁用例:入库 openapi.json 的版本与路径集必须与 build_spec() 一致。 既有用例只验「能生成、格式合法」,不比对入库文件,漂移才能无声积累到 13 个路径。 改路由忘了重新导出即红,修法写在用例 docstring 里。 本条对应 #116 里夹带的 openapi 重生成部分,独立提出;#116 主体(分级安全配置) 仍待其 rebase 后单独复审。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
复审结论:功能值得做,但请拆成三个 PR3495 行改动里混了三件互不相干的事,现在这个形态既难审也难回滚。 1.
|
实现内容
gateway_input、gateway_output、tool_return、assistant_intent四区域检测器配置,兼容既有扁平detectors配置。air_gapped)预设,支持区域覆盖与运行时原子热更新;隔离档仅允许 loopback Judge endpoint。GET/PUT /admin/security-config,受settings.view/manageRBAC 保护;配置变更写入审计链,Judge API key 不会在读取接口中明文返回。验证
uv run pytest:893 passed,2 skippeduv run ruff check src testsuv run ruff format --check src testsuv run pyright:0 errors(保留 1 个既有 all warning)uv run lint-importsconsole: npm run build当前边界
dev独立实现。