Skip to content

refactor(db): 写操作关卡收回 facade——单一写入口 executeMutationWithApproval - #10

Merged
zavier merged 1 commit into
refactor/related-cache-llm-contextfrom
refactor/mutation-gate
Aug 1, 2026
Merged

refactor(db): 写操作关卡收回 facade——单一写入口 executeMutationWithApproval#10
zavier merged 1 commit into
refactor/related-cache-llm-contextfrom
refactor/mutation-gate

Conversation

@zavier

@zavier zavier commented Aug 1, 2026

Copy link
Copy Markdown
Owner

变更内容

把校验 + 人工确认的仪式从 db_mutate 工具收进 DatabaseWorkspaceService(architecture review 候选 1):

  • 单一写入口:新增 executeMutationWithApproval(sql, opts, confirm),内部按
    prepareMutationQuery(DDL 抛 MutationValidationError)→ resolveTarget
    confirm(注入回调,生产 = showMutationConfirm)→ 执行 编排;
    删除无门 executeMutation,facade 上不存在绕过路径
  • 单一形状MutationApprovalRequest 合并校验结果 + 解析后目标;
    showMutationConfirm 改用该类型,消除 MutationConfirmParams 平行定义
  • 工具收缩db_mutate 只做参数装配与结果整形——
    instanceof MutationValidationError 区分 SQL rejected / Mutation failed
    用户拒绝走非 isError 结果(回显被拒语句)
  • 测试(+5):DDL / 无目标时 confirm 不被调用、拒绝不触达 manager、
    request 形状、无 WHERE 警告透传
  • 文档同步:mutation-tool-design / architecture / CLAUDE / AGENTS

已知边界

executed(批准→执行)分支需真实 MySQL 或 manager 注入接缝,留待候选 6(driver seam)落地后补测。

验证

  • npm run check 通过
  • npm test(vitest,228 tests)通过
  • npm run lint(oxlint,0 errors)通过
  • npm run fmt / npm run fmt:check 通过

stacked 在 PR #9refactor/related-cache-llm-context)之上,合并链:#8#9#10

把校验 + 人工确认的仪式从 db_mutate 工具收进 DatabaseWorkspaceService:
- 新增 executeMutationWithApproval(sql, opts, confirm),内部按
  prepareMutationQuery(DDL 抛 MutationValidationError)→ resolveTarget →
  confirm(注入的回调,生产 = showMutationConfirm)→ 执行编排;
  删除无门 executeMutation,facade 上只有一个写入口
- MutationApprovalRequest 合并校验结果 + 解析后目标,单一形状;
  showMutationConfirm 改用该类型
- db_mutate 只做参数装配与结果整形:instanceof MutationValidationError
  区分 "SQL rejected" / "Mutation failed",用户拒绝走非 isError 结果
- 测试:DDL/无目标时 confirm 不被调用、拒绝不触达 manager、
  request 形状与无 WHERE 警告透传(executed 分支待 manager seam)
- 文档同步:mutation-tool-design / architecture / CLAUDE / AGENTS
@zavier
zavier merged commit 89a1619 into main Aug 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant