- Move generated OpenAPI bundles out of dist/ into committed specs/ (specs/openapi.json, specs/openapi.raw.json); source YAML tree moves openapi/ -> specs/openapi/; schemas/workflow-schema.json joins as specs/workflow-schema.json - Update all generators/consumers: bundle-openapi, generate-raw-openapi, check-version-sync, bump-version, export-workflow-schema, packaging/embedded-openapi - Rewrite stale .env.example with current HOSE_* environment variables - Archive stale repo-local enterprise configs (superseded by ~/.config/hose-use/enterprises) out of the repo; root enterprises/ keeps only the tracked example.json plus an explanatory README - Add missing directory READMEs: approval/contact/message/task/events domains, cli/, http/, packaging/ - Fix stale domain doc links in README.domains.md and docs/modules/platform.md
1.6 KiB
1.6 KiB
Approval 智能审批引擎域说明
本域是 AI PRO 的智能审批引擎:DSL 规则解析、确定性安全网关仲裁、要点核验与基于 core/db 的会话持久化。采用六件套微架构,导出形状统一经 index.ts barrel 暴露。
架构
parser.ts:DSL 解析层,parseRuleBody将自然语言/结构化规则文本解析为ParsedRule,validateRuleBody/validatePreferenceText提供语法校验。gateway.ts:确定性仲裁门禁。analyzeFindings汇总要点核验结论,validateGatewayAction校验决策动作合法性,evaluateGatewayPolicy/ApprovalGatewayPolicy实现策略仲裁(默认策略defaultGatewayPolicy)。repository.ts:数据访问层,ApprovalRepository基于core/db管理审批规则、偏好、运行记录(run)、要点(finding)与 AI PRO 日志的持久化。service.ts:业务编排层,ApprovalService.injectAuditPoints(要点核验注入)与decideAudit(确定性审批决策)。db.ts:SQLite schema 初始化与连接管理(getApprovalDatabase,路径可经HOSE_APPROVAL_DB覆盖),迁移统一收敛至core/db/migrations.ts。types.ts:StrictnessTier、ParsedRule、ApprovalDecision、ApprovalRunRecord等模型定义。
关键约束
- 决策必须经 gateway 仲裁:
ApprovalDecision为封闭枚举(APPROVE/REJECT/PASS_WITH_NOTE/REVIEW/PENDING/ERROR),写动作由validateGatewayAction卡点。 - 规则严格度分四级:
硬性/弹性/建议/特殊。