Files
hose-use/src/domains/approval
gitea 95eb8ee676 chore(legacy): remove ekb-mcp migration layer, approval db compat shim, and stale daily notes
The ekb-mcp -> hose-use rename migration (LEGACY_* constants,
syncLegacyEnterprisesDir/syncLegacyGlobalConfig with 7-day grace
cleanup, dual-source enterprises resolution) has completed its job:
legacy data self-deleted on active machines years of grace ago.
Config resolution now returns the single primary
~/.config/hose-use source; startup no longer scans the legacy dir.

- core/config/loader.ts: drop legacy constants, sync functions, and
  LEGACY path from diagnostics candidates; loader.test.ts drops the
  three legacy-migration cases
- domains/approval/db.ts deleted: pure pass-through over core/db whose
  consumers (repository.ts) already call core/db directly; the four
  test files now import getDatabase/closeDatabase from core/db
- scripts/dev-hygiene.ts: drop the config.legacy finding and
  legacyConfig snapshot field
- docs/daily/* removed: Python-era (ekb-cli/ekb-mcp) notes describing
  commands and architecture that no longer exist (preserved in git
  history)

No behavior change on machines without legacy data: tsc clean,
313 tests pass (316 minus the 3 removed legacy cases).
2026-10-05 16:29:19 +08:00
..

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 卡点。
  • 规则严格度分四级:硬性 / 弹性 / 建议 / 特殊。