Skip to content

修复照片横线纸排版,并让 MCP 在交图前逐行验收 - #94

Merged
SXP-Simon merged 4 commits into
mainfrom
fix/mcp-ruled-photo-review
Dec 1, 2026
Merged

SXP-Simon merged 4 commits into
mainfrom
fix/mcp-ruled-photo-review

Conversation

@SXP-Simon

@SXP-Simon SXP-Simon commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

复现

在一张 1440 × 1920 的斜拍横线纸上,生成任务把固定的两列采样点当作整条横线的左右端点。作业排版还会在可写区两侧各加 6% 缩进。下半页横线逐行变宽,首笔仍接近同一个画面横坐标。上方纸张有弯曲,部分横线相对直线拟合偏离约 12 像素。

原检查将基线与附近暗纹的距离按页面三等分汇总。字体基线对齐时,下伸笔画仍可能越线,汇总值也解释不了每一行离实际左端有多远。

改动

  • 手工标定可以逐条提供原图端点和可选的曲线中间点 via。新建或重测的稿件使用标定的书写区,保留编号小缩进,按格内剩余空间给实际墨迹留白。原生流程图和电路图保留自然比例,图后正文回到横线格。已有稿件重放时保留原布局。
  • 普通图片预览直接返回 ruled_row_check。原纸上追踪到的上下印线与同版成图差分给出每行最小净空、首笔偏移和相对格高,提示优先检查的行及原尺寸裁图。图文重叠、线段过短或缺少局部实线时保留不确定性。
  • 整页复查按版本保存行证据。图形检查报告四角相对于参考线的位置,以及左右各跨多少格。导出回执列出同版记录中疑似紧邻、越线或多行挤入同一格的页面和检查单 ID。

本机实验

实验 结果
原稿重放 用保存的修订重新渲染,RGB 与原 PNG 逐像素相同。沿原纸独立追线,14 行正文中有 10 行距印线中心不超过 2 px 或越线。图下七行的首笔偏移由 175 px 增至 254 px。
弯曲线标定 保持相同左右端点,在原纸首四条正文底线上采样。线中心绝对误差的第 95 百分位由 12.64 px 降至 1.49 px。
固定原稿笔迹参数 沿用 34 px 字号、原稿的字号与位置抖动、墨色、字距及种子,仅让新标定接管冲突的版心边距。独立按墨迹到印线中心 ≤2 px 或越线计数:旧引擎加真实端点为 11/12 行,新引擎加相同端点为 4/13 行,补充弯曲实测点后为 0/13 行。
同纸重排 使用原题、李国夫手写体及同一随机种子,示范稿统一为 31 px 并减小抖动。最终 12 行正文在有印线支持处测得的上、下最小净空分别为 11 px 和 1.5 px,三个编号行首笔偏移为 52、51、53 px。9 个格的部分区段缺少证据,另看整页和原尺寸局部。
独立客户端 未提供故障清单的 agent 通过整页普通预览和一次原尺寸裁区检查,定位到旧稿的起笔漂移、压线和状态图箭杆与横线重合,判定暂缓交付。
其他版式 合成银行家算法表格和原生电路页分别测试。正文指标排除图表内部;电路的左、右图边各跨约 4.9 格。

回归覆盖多个随机种子、拉丁下伸笔画、编号换行、极端字号抖动与分页、历史标定重放,以及通过真实 MCP 操作故意制造压线后再从 PNG 中独立验证。示范稿另做过原尺寸图内检视。微调节点与标签后,中央箭杆在同一列到印线中心的距离由约 8 px 增至 31 px,图前图后正文逐像素相同。用户的实拍底纸与稿件仅保存在本机。

验证

  • Rust 1.94.1 完整工作区通过 cargo fmt --all -- --check、cargo clippy --locked --workspace --all-targets -- -D warnings 和 cargo test --locked --workspace(282 项通过,1 项扩展视觉测试按仓库设置忽略)。
  • 使用重新构建的 Markdown worker 和最终 release 二进制通过 MCP 完整 stdio smoke,另独立运行了 ruled_row_alignment.py、diagram_perspective.py、coursework_form.py。
  • 最终 PR 二进制在全新图片预览中重放原稿与校正样张,分别与对应保存 PNG 的完整 RGB 像素一致。

Summary by Sourcery

Improve writing placement and delivery checks for photographed ruled paper using measured row geometry and per-row review evidence.

New Features:

  • Add row-by-row clearance, first-stroke offset, and relative glyph-height checks for photographed ruled paper, with native-size crop suggestions and versioned review evidence.
  • Report diagram corner positions and edge spans in ruling-row units, and include reviewed pages with flagged ruled cells in export receipts.

Bug Fixes:

  • Align newly created and retuned homework layouts to each manually measured ruling’s actual endpoints, preserving numbered-line indents and clearance below descenders.

Enhancements:

  • Support curved ruling guides with up to seven intermediate photo-space points while preserving historical layout replay behavior.

Documentation:

  • Update MCP guidance for measuring ruled-paper guides and reviewing row-level writing and diagram placement.

Tests:

  • Add coverage for guided row placement, curved projections, ruled-row evidence, diagram row positions, and end-to-end MCP review and export checks.

Chores:

  • Add an unreleased changelog entry describing the ruled-paper layout and review changes.

背景:手工标定的纸张仍会叠加作业版心缩进,字体基线贴齐也可能让下伸笔画碰线,斜拍纸张上的弯曲横线难以用两个点表达。

解决手段:新建或重新标定的手工参考线保留实测端点和可选中间点,按实际笔迹与格高留白,编号首行保留缩进,原生图形按整格预留空间。

收益:书写区域随每条横线变化,正文与图后首行可按同一尺度检查,历史稿件沿用保存时的排版策略。
背景:按页汇总的基线偏差和图框无法说明每一行实际墨迹是否碰到印线,普通预览也难以定位起笔或字号异常。

解决手段:在原纸追踪横线,将字框内可归属的成图差分逐列对照印线边缘,返回每行净空、首笔、相对格高和原尺寸裁区;图框报告跨格位置,导出回执引用同版待复核页。

收益:客户端在普通预览中即可定位疑点,能区分确有墨迹变化、缺少实线依据和图文重叠,按同一位置复核修订后的成品。
背景:合入首次交付报告后,两个功能的未发布条目位于同一位置。

解决手段:合入 main 并保留两项变更说明。

收益:横线纸改动可在最新主分支上独立验证。
背景:固定采样列会抹去列间的纸面弯曲,排版、反向取样和逐行验收会偏离手工标定。

解决手段:为新曲线保存相邻参考行的折点,沿同一投影生成和追踪墨迹,覆盖存储重放、行间插值、双向坐标和实际像素。

收益:在实测位置保留线形,同时沿用历史稿件保存的九列投影。
@sourcery-ai

sourcery-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Reviewer's Guide

Data structures

新增并持久化手工横线排版策略、曲线投影点及逐行复查状态,使新稿可采用实测布局而旧稿仍能按保存策略重放。

  • crates/handwriting-core/src/parameters.rs L106-108, L162
  • crates/handwriting-core/src/photo.rs L36-44 (+3 small edits)
  • crates/panache-mcp/src/drafts/observations.rs L197-200, L419-423 (+4 small edits)
  • crates/panache-mcp/src/engine.rs L490
  • crates/panache-mcp/src/paper.rs L32-70, L96-99, L278-396 (+9 small edits)
  • crates/panache-mcp/src/review/consistency.rs L51-623 (6 small edits)

API

扩展手工标定输入以接受按横线测得的左右端点和最多七个有序曲线中间点,并更新工具调用说明以指向标定与逐行检查。

  • crates/panache-mcp/src/inputs.rs L123-130, L176, L249
  • crates/panache-mcp/src/main.rs L357-781 (4 small edits)

Uses of the API

让普通图片预览生成横线纸复查数据,并在保存和导出流程中提示逐页核对及列出已有检查单的可疑页面。

  • crates/panache-mcp/src/main.rs L899, L920-923, L1022-1025
  • crates/panache-mcp/src/preview.rs L270-274, L293-310
  • crates/panache-mcp/src/save.rs L302-307

Implementation

让手工标定的横线以折线形式参与投影和反投影,并据此构造逐行书写区域。

  • crates/handwriting-core/src/imaging/rulings.rs L356

在手工横线布局下按可见墨迹边界安排正文、保持编号缩进,并为原生图形预留整格且将图后正文接回行格。

  • crates/handwriting-core/src/render.rs L192, L252
  • crates/handwriting-core/src/render/homework.rs L7-10
  • crates/handwriting-core/src/render/line.rs L36-52, L94-116 (+3 small edits)
  • crates/handwriting-core/src/render/paragraph.rs L61-75, L77 (removed lines)

将原纸横线追踪、逐行墨迹净空与起笔测量,以及图框相对格线的位置计算接入复查和预览。

  • crates/panache-mcp/src/review.rs L187-193, L200-214, L481-484 (+4 small edits)
  • crates/panache-mcp/src/review/drawing.rs L99-112 (+3 small edits)
  • crates/panache-mcp/src/review/ruled_rows.rs L1-272
  • crates/panache-mcp/src/review/ruled_rows/tracking.rs L1-249

Documentation

更新变更记录、操作指南和 MCP 使用说明,解释逐行端点标定、曲线测点及交付前复查方法。

  • CHANGELOG.md L5-6
  • crates/panache-mcp/README.md L176-181
  • crates/panache-mcp/tool-design.md L41

Tests

验证手工曲线标定、历史布局重放、边界墨迹排版、图形占格和大字号分页行为。

  • crates/handwriting-core/tests/generation_pipeline.rs L93-237
  • crates/panache-mcp/src/review/paper_ink.rs L334
  • crates/panache-mcp/src/review/ruled_rows/tests.rs L1-218
  • crates/panache-mcp/tests/diagram_perspective.py L61-70, L108-114 (+2 small edits)
  • crates/panache-mcp/tests/ruled_row_alignment.py L1-128
  • crates/panache-mcp/tests/smoke.py L31, L517

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 December 1, 2026 20:45
@SXP-Simon SXP-Simon added the run-ci 手动批准当前 PR 版本的相关 CI 检查 label Dec 1, 2026
@sourcery-ai

sourcery-ai Bot commented Dec 1, 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 5 days and 14 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@SXP-Simon
SXP-Simon merged commit c685bf8 into main Dec 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci 手动批准当前 PR 版本的相关 CI 检查

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant