Skip to content

fix(crates/panache-mcp): 指明照片上墨迹边缘的柔化条件 - #28

Merged
SXP-Simon merged 3 commits into
mainfrom
fix/mcp-photo-ink-guidance
Nov 25, 2026
Merged

SXP-Simon merged 3 commits into
mainfrom
fix/mcp-photo-ink-guidance

Conversation

@SXP-Simon

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

Copy link
Copy Markdown
Owner

本轮补充了局部和整稿两种柔化方式。只改某一行时,先选中这一行的字;用户点名要保留的地方,改后也要对照。两行稿示例与 24 场模型实测

问题与改动

真实底纸上的字像后来贴上去,可能是边缘过锐,也可能是光照、阴影或墨色对比。只在照片整页复盘的 photo_appearance 增加条件引导:边缘确实比附近可比较的实拍痕迹更锐利时,才考虑小幅试调 ink_softness;在同一原尺寸区域复看细笔和对比度。用户要求不变、边缘已经合适或不确定时保留原样。阴影或墨迹淡本身不是柔化根据,无图不代替用户判断。

没有改渲染、默认值、放置、字体、归档或全局工具提示。仅新增回执引导字段、专项断言和未发布记录;与 #26、#27 的改动独立。

本地实测

基线 e1e2546a 与候选都用 Rust 1.94.1 本地构建,使用相同的校验过的 Markdown worker 和字体,Python MCP SDK 1.29.0。候选新增字段外,其余跨臂照片回执字段一致(忽略独立稿件 ID)。专属 stdio 回归、格式和 diff 检查通过。

  • 1100×640 合成底纸、固定 seed 27、同一区域和真实 PNG:ink_softness 0→0.8 时目标裁图改变 3,908 个像素,右侧保护区 0;原尺寸底纸和成品裁图与对应整页区域一致。像素变化只证明渲染不同,不证明更自然。
  • 阴影反例:不透明度为 0 时位置仍有 8 个基线测量,工具报告 no_visible_change。位置统计不能用来背书可见性。
  • 八条独立 native 模型轨迹,各臂使用真实 MCP、隔离 SQLite 和同一批受控条件。两组正例都走 ink→试调→同一区域对照,各 3 次调用,基线与候选均完成;正文、主字体、其它控件、区域几何和已有复盘不变。模型只见图片哈希,未做目视判断。
  • 两组文字客户端负例(阴影深但没要求改),GPT-6.1 Terra low 与 GPT-6 Luna low 各一对:均从 2 次调用降到 1 次,只读档案而非额外拉取图像;后续工具响应分别从 23,375→2,742 B、24,647→2,742 B。初始带引导的 photo_appearance 增加 596 B,未计入前两个对照数。两臂均无新版本、复盘或导出。小样本只支持这两类试例,不推广到可看图场景。

草稿,不加标签,不手动触发 Actions。

Summary by Sourcery

Guide photo reviews to soften ink only when edge sharpness is clearly established and verify the result against the original region.

New Features:

  • Add photo-review guidance that distinguishes overly sharp ink edges from shadows or faint ink and recommends cautious, localized softening only when supported by user feedback or crop comparison.

Enhancements:

  • Improve post-edit review instructions to compare paper, before, and after crops while checking fine strokes, contrast, and explicitly preserved areas.
  • Keep photo-specific guidance scoped to photo reviews and exclude it from crops and archived review records.

Documentation:

  • Update the panache-mcp guide with conditional ink-softness review guidance and workflows for localized or whole-draft adjustments.

Tests:

  • Extend review and context metrics tests to validate the new guidance, its scoping, archived review behavior, and response sizes.

Chores:

  • Record the photo-review guidance change in the changelog.

背景:照片复盘已有原尺寸裁图和墨迹控件,但阴影、墨迹偏淡与真正的边缘过锐并不是同一问题,文字客户端也可能无效拉取裁图。

解决手段:只在照片复盘回执增加条件说明。边缘确实比附近痕迹锐利时才考虑小幅柔化;同区域对照细笔和对比度,没图不代替人判断。

收益:两组真实文字客户端负例均从两次调用降到一次且无写入;两组实际柔化任务仍完成原对照。未改变渲染或已有参数。
@sourcery-ai

sourcery-ai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Add photo-review guidance that distinguishes supported evidence of overly sharp ink edges from shadows or faint ink, and requires cautious, same-region comparison after an adjustment.

  • crates/panache-mcp/src/review.rs L310-313

Documentation

Explain the criteria and workflow for selectively softening photographed handwriting, and record the change in the changelog.

  • CHANGELOG.md L9
  • crates/panache-mcp/README.md L119-121

Tests

Cover the new photo-review guidance, verify it is absent from crops and archived or non-photo reviews, and include photo-review response sizes in context metrics.

  • crates/panache-mcp/tests/context_metrics.py L20-25, L41-42, L86-105
  • crates/panache-mcp/tests/review_comparison.py L46-51, L69-87, L126-136 (+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

Copy link
Copy Markdown
Owner Author

原始判据与复跑

固定合成底纸 1100×640、字号 34、seed 27,含左侧拍摄线、模拟阴影和右侧保护图案。用 save_section 建稿、tune_handwriting(paper_guides=…) 放到左侧,已有全页复盘收据只在夹具阶段生成一次。正常轮次开启 PANACHE_MCP_PRESERVE_REVIEWS=1,每轮复制独立数据库。MCP SDK 逐次转发,图片只用测量和哈希,不把字符串当成模型看图。

  • Luna 边缘正例:实际 ink_softness 0→0.2,两臂各 3 次、0 错误,MCP 后续响应均 40,505 B。Terra 同类留出:0→0.3 对 0→0.2,仍各 3 次、0 错误,未评价谁更好。
  • Terra 文字负例(用户说阴影深、边缘合适、不要改):基线 preview_handwriting 区域对照 + 查墨迹参数,候选只读旧检查单。Luna 留出(灯影下字显淡、客户端无图片、不要调参):基线旧单 + 额外区域预览,候选只读旧单。后续响应 23,375/24,647 B → 2,742 B,初始工具回执加了 596 B。两对都没改稿或留新记录。
  • 断言观察稿件 revision、正文、主样式、除柔化外的控件、纸张设置、复盘/反馈/导出的 SQLite 状态。正例两版用相同 region 与 compare_revision;负例的柔化和 revision 保持原值。没有宣称全量用户的准确率提升。

复跑:Rust 1.94.1。cargo build --locked --release -p panache-mcp,设置 PANACHE_MARKDOWN_WORKER 与 PANACHE_FONT_DIR,执行 python3 crates/panache-mcp/tests/smoke.py target/release/panache-mcp 可运行含 unruled_artwork 的专属回归。保持草稿,无 CI 标签。

Copy link
Copy Markdown
Owner Author

原图盲评补充:没有证据默认柔化

基于真实 main MCP、固定底纸/正文/参考线、seed 27,对「边缘可能偏硬」「阴影下字淡」「笔画已经偏细」三类合成页,按 ink_softness=0/0.2/0.5 两两生成 9 张 340×136 原尺寸裁图对。左右位置与出题顺序随机,部分独立会话再左右互换。四个独立 GPT-6.1 Terra medium 会话实际看到了像素,不给参数表、方案标签或预期答案。

  • 每组目标像素变化 3,634–3,893,预设保护区均为 0。
  • 与纸面痕迹是否协调:36 票中 18 无法判断、6 平,剩余 11 票偏低柔化、1 票偏高。附近参照只是一条细线,不能据此宣称照片融合更自然。
  • 细笔/可读性:20 票偏低柔化、4 票偏高、12 平。预先减细的样本 9/12 偏低、3/12 平。这不是人评,也不是 36 个独立场景或任何默认值的胜率。

这支持保留当前条件说明:仅有具体过锐迹象才小幅试,细笔已弱、不确定或只看到阴影时不默认上调。盲评不改变本 PR 原来的路由/负例结论。

背景:
照片复盘的固定长引导会同时出现在两种回执表示中。

解决手段:
在回执保留试调条件和同区域核对动作,把例子移入中文说明。用真实 SDK 验证照片、非照片、裁图和只读旧复盘。

收益:
合成照片夹具完整回执少 840 字节,同时保持什么时候试调和怎么检查的约束。仅统计回执字节,不折算 token。

Copy link
Copy Markdown
Owner Author

续测:保留触发条件,把长示例移到中文指南

本次只缩短照片复盘引导,不改渲染、默认参数或复盘存储。保留「用户明确指出笔画过锐或原尺寸图有可比锐边」才小幅试柔化;阴影/偏淡单独不触发。改后仍用同一区域看真实前后图、细笔和对比度;不确定就保留原版。

独立云任务用 SDK 1.29.0 实际量整页回执:父提交 37,232 B、原草稿 38,428 B、本版 37,588 B,较原草稿 −840 B;单份 photo_appearance 为 844 → 1,440 → 1,020 B。原报告的 +596 B 是单份字段,不是完整 SDK 回执。非照片整页/只读旧收据分别维持 145,668/2,678 B;旧检查单证据和 SQLite 状态不变。未把回执字节折算 token,也未测自然度。

精确发布 35f758202b45948918bbb1c2d0cea1fff717abb0/tree f750604e046bd68ce6bbde6d7c3308d8d80721d2。根重新独立构建,Rust 8 通过、0 失败,实际 SDK 完整 smoke.py 通过。仅开放草稿,未合并、无标签、0 次 Actions。

背景:整页照片检查只提到整稿柔化,用户只要求改一行时,模型可能连带改动其它行。

解决手段:提示模型按范围选择单字或整稿工具,复看用户点名保留的区域,文字模式交代观察来源,并同步使用说明和回归断言。

收益:模型在选择工具时能区分一行和整篇,也能向用户说明保留原样的依据。
@SXP-Simon

Copy link
Copy Markdown
Owner Author

这次补充想解决一个具体问题:用户说“第一行的字边太硬,帮我调柔和一点,第二行我很满意,别动”。这就像在 Word 里改字号,选中第一行和按 Ctrl+A 全选,都会让第一行发生变化。只看第一行,发现不了第二行也被改了。

现在 AI 做整页照片检查时,会收到三个提醒:

  • 只改第一行,就先找出这一行的字,用 adjust_glyphs 只调这些字。用户要改整篇,才用 tune_handwriting 调整全稿。原来的判断条件仍然适用:纸面有阴影或字淡,本身不足以说明笔画边缘需要柔化。
  • 改完对照第一行的前后图。用户点名第二行要保留,也要看第二行的前后图。
  • 如果只能收到文字,就说清楚依据来自哪里。比如用户说“边缘已经合适”,可以回答“既然你觉得合适,就保留”。要说“检查看到了什么”,得有图片或测量结果支持。

这样做有什么用? 用同一份两行稿,把柔化力度都设为 0.3。用整稿设置,第二行有 4,163 个像素发生变化;只选第一行,第一行柔化了,第二行逐像素完全相同。此前一次 Luna 试验就误用了整稿设置,还告诉用户第二行保留了,实际第二行有 4,192 个像素变化。

多一句提醒,AI 就更可靠吗? 我们用 GPT-6 Luna 和 GPT-6.1 Terra 在同样的稿件、同样的要求下,对比本 PR 补充前后的表现。每个版本每种场景各做 4 次,共 24 场有效的两轮对话,并核对了工具调用和存下来的图片。

看什么 补充前 补充后
要求只改第一行,第二行实际保持原样 4/4 4/4
改完后,对照图确实覆盖了指定保留的第二行七个字 3/4 3/4
明确要改整稿,两行都变柔和,字色和排版保留 4/4 4/4
只收文字,正确保留原稿并说清判断依据 3/4 4/4

实验证实了选对工具能保住第二行。至于这段提示能把误改率降多少,样本还不够。补充后仍有一次把第一行检查了两遍,漏看了第二行。文字场景里,原版有一次把用户说的阴影当成工具测到的结果,补充后的四次都交代清楚了。

这段提示放在新做的整页照片检查里。另有一次只读到旧检查记录,没有收到提示,已单列并补跑。在这张测试照片上,整页检查结果多了 520 字节,局部裁图和前后对照的大小没变。

@SXP-Simon
SXP-Simon marked this pull request as ready for review November 25, 2026 10:29
@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 18 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@SXP-Simon
SXP-Simon merged commit 1566aad 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