refactor(db): 写操作关卡收回 facade——单一写入口 executeMutationWithApproval - #10
Merged
Merged
Conversation
把校验 + 人工确认的仪式从 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
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.
变更内容
把校验 + 人工确认的仪式从
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 结果(回显被拒语句)
request 形状、无 WHERE 警告透传
已知边界
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 #9(
refactor/related-cache-llm-context)之上,合并链:#8 → #9 → #10。