Skip to content

fix: 恢复底纸参考线时保护已确认的手动摆字 - #48

Merged
SXP-Simon merged 3 commits into
mainfrom
feat/mcp-guide-reset-protection
Nov 25, 2026
Merged

SXP-Simon merged 3 commits into
mainfrom
feat/mcp-guide-reset-protection

Conversation

@SXP-Simon

@SXP-Simon SXP-Simon commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

问题与变更

整合 #27 的手动摆字保护和 #45 的参考线说明。两份原稿基于同一版本,整合时在 Tune 保留了相邻的两个参数。本草稿独立面向 main。

用户把首字移到签名格、定好行距和左边距后,又说「把底纸横线换回上传时那套,其他照旧」。同一次重置里填回行距和边距可以保存两个数值,首字仍会随全页重排。现在 AI 在选择 tune_handwriting 和填写 paper_guides 时都能看到手摆保护提示。

  • 需要保留先前摆好的字时,在本次请求传 preserve_local_adjustments=true。如果重排会使当前仍生效的局部调整失效,整次操作在写入前停止,现有版本保持可用。
  • 只需保留指定行距或边距时,在同一次 changes 中补回用户已确认的值。想继承底纸时省略对应值。
  • 用户明确允许重新排字时可继续重置。保护参数仍为可选,纯墨迹或拍摄信息修改可以照常保存。

Luna 和 Terra 的实际操作

Windows x64,Codex CLI 0.171.0,gpt-6-luna 和 gpt-6.1-terra 均用 low。每个版本、场景、模型使用独立会话和同一初始 SQLite 稿件的独立副本。模型通过标准输入输出连接真实 Panache MCP,收到对应可执行文件的完整工具目录,仅用 Panache 操作稿件。两轮场景在同一会话继续,核对第一轮没有写稿。模型看不到版本分组、评分标准或另一个模型的答案。

用户要求 当前 main 原样整合 #27 + #45 加入交叉提示
跨两轮,明确说冲突就保留当前版 0/2 2/2 2/2
跨两轮,第二轮只说「其他照旧」(含独立复试) 0/4 2/4 4/4
无手摆,重置并一次保存文字行距 56、左边距 67 1/2 2/2 2/2
无手摆,重置并让数值继承底纸 2/2 2/2 2/2
有手摆,用户明确允许重排并保留两个数值 2/2 2/2 2/2

前两行统计遇到冲突后零写入保住原稿的次数,后三行统计一次保存即得到指定状态的次数。冲突场景核对当前修订、数据库逻辑内容、首字四角和预览 PNG 一起保持不变;另核对模型是否如实说明执行结果。允许重置的三组要求恰好保存一版、底纸校准回到导入值、文字覆盖值按要求保留或清除,放弃手摆时还核对新版首字确实回到自动位置。以 stdio 实际请求和重新打开的稿件为准。另有一例值得单列:当前 main 的 Terra 在「其他照旧」复试里连续保存四版,最后成功恢复导入校准、保住 56/67,并把首字四角移回原坐标。整页 PNG 与起点不同;这例属于事后修回首字,不计入零写入保护。

额外提示的收益集中在「其他照旧」。 原样整合时 Luna 两次都动了稿。第一回补回了 56、67,却漏开保护,布局回执中的签名首字左上角从 (97, 102) 回到 (65, 86),回复却说其他调整已保留。第二回先收到保护拒绝,随后用 false 重试,再把字往回摆,多存两版,最终左上角在 (97, 100),比原来高 2 px。改进版两回都在同一请求中传了两个数值和保护开关,被拒后停在第 3 版;四角、整页 PNG 和 SQLite 逻辑转储均与开始时一致,并如实说明原因。Terra 在两种提示下均为 2/2。本轮只看到 Luna 在这一种表达上改善。

另外三个允许重置的场景中,两个模型使用新版均一次成功(6/6),分别保留指定值、清除覆盖值、或按明确授权放弃手摆。明确说「冲突就保留这版」时,原样整合和改进提示均为 2/2。当前 main 中 Luna 一次只提交参考线重置,覆盖值随之清空,还声称文字设置和手摆均已保留;Terra 一次尝试恢复后再重建设置和手摆,外观回到原样但已多出三版。

可复核的场景

合成底纸 600 × 800 px,导入时参考线间距 48、左边距 42,后续校准为 53、26。正文「西湖春早,柳色正新。」,字号 34、种子 73。第 2 版显式固定文字行距 56、左边距 67。需要手摆的场景在第 3 版另将首字右移 32、下移 14。每个模型每个版本各做以下五个任务,「其他照旧」另开新会话独立重复一次,总共 36 个试验。

  1. 明确冲突条件。第一轮确认两个数值和已摆好的首字,等下一条再改;第二轮要求恢复导入时的参考线,「前面定好的都留着,两件事能一起做到你就直接处理;冲突就保留这版,告诉我原因」。
  2. 跨轮省略手摆要求。第一轮说「签名格里的首字已经摆好了,这个位置我很满意;文字行距 56、左边距 67 我也确认了。帮我核对这是哪一版。」第二轮只说「只把底纸横线换回上传时那套吧,行距和左边距照旧,其他照旧。处理好告诉我。」
  3. 无手摆,要求重置并一次保存 56、67,其余随底纸。
  4. 无手摆,要求重置,行距和边距也继承底纸。
  5. 有手摆,明确同意首字回到自动位置,同时保留 56、67。

工程验证

  • 源码对应 b803c8b3(main)、aa7bfdb5(原样整合)、5d3803e9(本草稿)。三套 Windows 可执行文件分别固定;字体使用仓库资源,Markdown worker 由 Flutter 3.47.5 从当前源码构建。各组均使用同一套字体和 worker。
  • 实际 SDK 工具目录对照:后两个版本的 tune_handwriting 仅工具说明和 paper_guides 参数说明不同。另外观察到已有的随机 Style.seed.default 差异,单独列出。
  • Rust 1.94.1:cargo fmt --all -- --check、cargo clippy --locked -p panache-mcp --all-targets -- -D warnings 和 cargo test --locked -p panache-mcp 通过,9 项单测通过。
  • 完整 crates/panache-mcp/tests/smoke.py 通过,使用 Python MCP SDK 1.29.0、同一 worker 和仓库字体,通过真实 stdio 执行。
  • 新增 stdio 回归覆盖同一次请求传回行距和左边距并开启手摆保护。核对受影响的节和修订、当前字形四角,并用原版号验证下一次正常重置仍可执行。

这批对照使用一张合成底纸、两款模型和固定的中文措辞。计数描述本次模型行为,不能据此估算用户日常使用的成功率。

Summary by Sourcery

保护用户已确认的手动摆字,避免参考线或其他布局调整在未明确授权时覆盖现有稿件。

New Features:

  • 为 tune_handwriting 增加可选的 preserve_local_adjustments 参数,用于在参考线或布局变更可能影响手动摆字时保护当前稿件。

Bug Fixes:

  • 在保护模式下检测到局部字形调整会失效时拒绝整次重排,避免生成部分写入或破坏现有版本。
  • 增加并发写入检查,确保预检后发生字形修改时不会覆盖最新稿件。

Enhancements:

  • 明确参考线重置时已确认的行距和边距需要在同一请求中显式保留,并完善相关工具说明与错误提示。

Documentation:

  • 更新 MCP 使用文档和变更日志,说明手动摆字保护、参考线重置及布局值继承规则。

Tests:

  • 增加局部字形调整保护、并发修订冲突和参考线重置行为的回归覆盖。

背景:已有手动摆字的稿件调整笔迹变化后会推进布局版本,当前版不再应用原来的字形位置,工具只能在写后提示重查。

解决手段:为 tune_handwriting 增加可选保护条件,在布局失效前检查当前来源与布局版本的字形调整。使用既有修订校验阻止并发写入,返回受影响的节号并保留原版。纯墨迹、相机补录及不变的布局控件不误拦。

收益:实测避免手动字形从 (203,186.5) 回落到 (83,106.5),拒绝请求不会写入新版本;旧稿、双进程竞争和普通墨迹操作均通过本地回归。

(cherry picked from commit 77a673a)
背景:恢复参考线会清除已有的边距和行距覆盖值。

解决手段:说明在同一次请求中补回用户指定的值,或让其继承底纸设置。

收益:减少二次保存,避免把当前生效的所有值误当成用户的固定设置。

(cherry picked from commit 872451e)
背景:补回行距和边距仍会重排整页,助手可能遗漏前一轮确认的手摆位置。

解决手段:在调参入口和参考线说明中说明保护条件,在组合回归中核对拒绝后的位置与版本。

收益:用户同时要求恢复参考线和保留摆字时,助手可以在同一次请求中表达两项约束。
@sourcery-ai

sourcery-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Reviewer's Guide

API

Extend the tuning input with an optional preservation flag and explain how guide resets interact with saved layout overrides.

  • crates/panache-mcp/src/inputs.rs L115-120

Expose the preservation requirement in the tune tool description so callers can request it when revising a draft.

  • crates/panache-mcp/src/main.rs L350

Implementation

Reject protected reflows when active local glyph adjustments would stop applying, and reuse the revision-conflict message when advancing drafts.

  • crates/panache-mcp/src/drafts.rs L13-14, L173-197, L608
  • crates/panache-mcp/src/tuning.rs L111-113

Documentation

Document how to request glyph-adjustment protection and how to restore guides while retaining chosen spacing and margin values.

  • CHANGELOG.md L15
  • crates/panache-mcp/README.md L121-124

Tests

Cover the preflight-versus-write revision race and exercise protected guide resets, layout changes, and ink-only edits through smoke tests.

  • crates/panache-mcp/src/drafts.rs L48-71
  • crates/panache-mcp/tests/smoke.py L98-108, L651-664 (+3 small edits)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@SXP-Simon
SXP-Simon marked this pull request as ready for review November 25, 2026 09:45
@sourcery-ai

sourcery-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Sorry @SXP-Simon, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 4 days and 19 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@SXP-Simon
SXP-Simon merged commit f8d703c into main Nov 25, 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