Skip to content

fix(mcp): 不因等值数字的 JSON 写法重排稿件 - #33

Merged
SXP-Simon merged 1 commit into
mainfrom
fix/mcp-equivalent-number-overrides
Nov 25, 2026
Merged

SXP-Simon merged 1 commit into
mainfrom
fix/mcp-equivalent-number-overrides

Conversation

@SXP-Simon

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

Copy link
Copy Markdown
Owner

复现

把 word_spacing 显式固定为 4 后再送 4.0。两次的有效字距相同,旧版仍写入新修订与编辑记录。若这一页已有手动摆字,旧版还会丢掉当前摆放。反向 4.0→4 和“等值字距 + 真正改变墨迹”也复现。

改动

仅在原校验通过、控件类型为 number、已显式保存且两个解析后的值精确相等时,保留旧 JSON 表示。这会沿用已有的「设定未变化」结果或只应用该批中其余修改。首次显式固定默认值、null 清除、真值变化、整数类型校验和已有字形保护规则均不改。

验证

  • 两轮独立工作树、基线与候选实际 stdio/SQLite:每轮每臂 26 次调参。首次固定、合法小数、近似但不相等的值、清除都能保存;无效类型、越界和错误步长不写库。
  • 首轮手摆页对照:旧版单独等值修改抹掉摆放,出现 5,131 个不同 RGB 像素。连同墨迹改则与同页的纯墨迹对照差 4,454 像素。候选两种比较均逐字节相同。
  • Release 留出改用另一段文字、字体和 seed 重跑:基线 4,763 / 4,336 个不同像素,候选都是 0;候选纯等值停在现版,混合操作只新增一个修订并保持手摆。Rust crate 11 项通过,MCP 全套 stdio 冒烟通过。
  • 和既有 7 条 draft 做本地三方组合无冲突。保持无标签 draft,不触发 GitHub CI。

Summary by Sourcery

Preserve saved numeric parameter representations when a valid override does not change its effective value.

Bug Fixes:

  • Prevent equivalent integer and decimal JSON forms for already-saved numeric parameters from triggering unnecessary revisions or re-layouts, preserving existing manual glyph placement.

Tests:

  • Add coverage for equivalent numeric representations, changed and cleared numeric overrides, and validation of invalid or out-of-range patches.

已固定的数值控制 word_spacing=4 与 4.0 运行值相同,但旧实现将 JSON 表示变化视为新设定,新增修订并令已有的局部摆字失效。只对已显式保存、通过原校验的 number 控件识别 f64 相等,保留旧存储表示;保留首次固定默认值、null 清除、不同值、整数校验和实际墨迹更改。

两套真实 stdio 对照及 release 全量冒烟通过:单独等值改写不写库;与墨迹同改时只保存后者,手摆页与纯墨迹对照逐字节相同。用独立页、字体和 seed 复核,基线误差 4763/4336 像素,候选均为 0。无 GitHub CI。
@sourcery-ai

sourcery-ai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

在原有校验通过后,对已保存的 number 控件比较解析后的数值;若数值相等则保留旧 JSON 表示,避免等值改写触发新修订。

  • crates/panache-mcp/src/controls.rs L78-81

Documentation

记录 MCP 数值参数的等值整数与小数写法不会再导致重新排版。

  • CHANGELOG.md L12

Tests

覆盖等值数字保留原表示、数值覆盖的固定与清除,以及无效或越界补丁仍被拒绝的行为。

  • crates/panache-mcp/src/controls.rs L172-219

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

Copy link
Copy Markdown
Owner Author

实测复现与判据

  1. 用 Rust 1.94.1 分别在两个隔离 Cargo target 构建 e1e2546a 和候选,运行 Python MCP SDK 1.29.0、真实 stdio。设好 PANACHE_FONT_DIR、PANACHE_MARKDOWN_WORKER。两个独立夹具:李国夫手写体 seed 27,青叶手写体 seed 31。
  2. save_section 建合成稿;tune_handwriting(changes={"word_spacing":4}) 固定;从实际同页 view=layout 取得首字,用 adjust_glyphs(dx=120,dy=80) 手摆,再向当前版提交 word_spacing=4.0。旧版成功但当前字形回到原位;新候选返回既有 No control values changed,settings、edit_notes、修订和 PNG 保持。反向用先写 4.0、另改墨迹、再写 4 验证。
  3. 从相同手摆状态独立重建两份,分别应用 {"layout":{"word_spacing":4.0},"ink":{"ink_opacity":74}} 与单独 ink_opacity=74。候选保留同一活跃 glyph edit,两个 PNG 字节相同;首轮旧版有 4,454 个 RGB 像素差,release 留出 4,336 个。单独等值回归分别 5,131、4,763 行为差像素,候选 0。不是对一般稿件的估计。
  4. 各臂 26 次定向调参、包括首次显式固定默认 1、null、近似不等数字、实际 reflow、错误步长与整数控件输入 77.0。重复校验只在原类型校验之后,既不扩大可接受类型,也不使用四舍五入后的近似。旧历史库仍能读取原手摆版。
  5. cargo test --locked --release -p panache-mcp 11/11;python3 crates/panache-mcp/tests/smoke.py <release-binary> 全部通过。没有使用 GitHub CI。

Copy link
Copy Markdown
Owner Author

建议子集的云端兼容性复验

独立工作树把 #33、#32、#29 和 #39、#44、#41、#47 合在一棵本地树 b9d27997bda34f05ecf8ada8133bb3768a053a3a,不叠加已相互收口的 #26/#40。两层之间唯一冲突是 CHANGELOG 的游标与历史末页条目,保留两条。Rust 1.94.1 从独立空 target 构建,精确二进制 SHA-256 1063856d5f6384b9a7341d9b334606e94a463e0a9f125983c58b221c7f36809a。

@SXP-Simon
SXP-Simon marked this pull request as ready for review November 25, 2026 12:04
@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 2 days and 6 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@SXP-Simon
SXP-Simon merged commit 21e4b01 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