Skip to content

feat(crates/panache-mcp): 按补记前的版本和正文末页找回检查单 - #22

Closed
SXP-Simon wants to merge 4 commits into
feat/mcp-review-receiptfrom
feat/mcp-historical-page
Closed

SXP-Simon wants to merge 4 commits into
feat/mcp-review-receiptfrom
feat/mcp-historical-page

Conversation

@SXP-Simon

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

Copy link
Copy Markdown
Owner

接续 #20 的按版本、节、页只读查单。用户说“后来添上那句之前,正文写到最后的那张”时,客户端过去需要分别猜修订号与页码。某版有检查单的最后一页可能早于正文的最后一页;相邻版本同一页又可能恰好有单。

在现有 read_section(view="review") 中,before_text 使用保存的 Markdown 字面片段寻找唯一一次加入它的编辑,并选择紧前一版。page="last" 使用指定节在同一版的分页算出最后一页,再读已存单据。两项可分别使用。数字页仍是原查询路径。查不到、存在多个引入点(含同节删后再加)、原始稿已有该短语时均有明确结果或可操作的错误。命中回执区分版本归属与真实开单时间。

此 PR 的范围是历史定位和回归覆盖;基于 #20,可与 #21 的客户端范围示例分别审阅。实际弱模型对照、数据库和旧稿导出检查见实验评论。

Summary by Sourcery

Extend read-only review retrieval to locate the version before a unique text addition and query that version’s actual final page.

New Features:

  • Enable historical review lookup by identifying the revision immediately before a unique Markdown passage was introduced and querying that version’s actual final page.
  • Support page="last" in review reads by calculating the selected section’s final paginated page for the requested revision.
  • Return section choices and actionable errors for ambiguous passages, missing text, first-revision text, and multi-section lookups.

Bug Fixes:

  • Distinguish the revision a saved review belongs to from the time it was actually created when reporting anchored historical results.

Enhancements:

  • Add a render-only page-counting path so historical page lookup does not generate images or new review records.
  • Document the new historical lookup parameters and their ambiguity and section-selection behavior.

Documentation:

  • Document locating reviews before an added passage and reading the historically paginated final page.

Tests:

  • Add regression coverage for historical final-page lookup, ambiguous and repeated introductions, multi-section drafts, image-containing sections, and non-mutating reads.

背景:跨版本查验时,修改前的稿件与后来版本可以在相同的页码留下不同单据,也可能只有前几页做过检查。

解决手段:在按页查单时支持用独有原文字串解析其首次加入前一版,并按该版稿件的实际分页定位目标节末页,返回匹配的修订和原单据。歧义和无前版情况显式报错。

收益:客户端可在同一次只读调用核对版本、页码和反馈来源,缺单位置无需新建记录,现有按编号和数字页查询保留原路径。
背景:同一节中的补记可能被删除并重新加入,按最初含该字串的版本定位会掩盖两个可能的编辑边界。

解决手段:按每一节的修订顺序查找从缺少到包含原文的转换,只有唯一的引入事件可以绑定前一版。增加连续保留、删后重加、跨节重复和明确版本回退的回归覆盖。

收益:用户描述存在多个可行解释时,助手可以请求明确所指编辑,避免将真实检查单套到另一版。
背景:用户尚未说明哪一次补入原文时,笼统的歧义报错仍会让客户端自行代选一个历史版本。

解决手段:按时间列出最早两次引入的节和版本,给出可直接读取的前一版。标明首次建稿没有前版、候选过多时仅列示例,并提示询问用户或分别核对。

收益:客户端可以使用用户熟悉的先后关系确认要查的稿件,歧义回执不混入任何候选检查单。
背景:重复引入时给出的编辑节号容易被误用为查单的目标节,多节旧稿省略节号还可能意外选中第一节。

解决手段:在各版本选项中列出有界的节号与正文开头,同节反复补入仅显示时间。相对定位或查末页时,多节稿需指定目标节;传统数字页查询沿用原有默认。

收益:可按用户要查的正文选择版本和页,节提示不会展开内嵌图片,也不会生成检查单。

Copy link
Copy Markdown
Owner Author

实验复核:先锁旧版本,再找那一版真正的末页

对照是 #20 的 4328a5e,其中已有按坐标原样查单和空回执;完整工具组提供 13 项,历史查询工具组按 #21 只提供 2 项。每次开一个新的 gpt-5.6-luna / low,使用相同的隔离稿库副本,所有数据通过正常 MCP 建立。测试只给自然语言请求,模型不能读数据库或源码。错误时用户只指出“我记得不止一张”或“我问加上以前”,不提示版号、节号、参数或答案。

场景 #20 完整 / 限定工具 本 PR 完整 / 限定工具
补记加入前的正文末页没有整页单,当版第 1 页及后来的末页都有单 此轮首答 0/2。一个给了旧版第 1 页的单,另一个给了后来版本末页的单。自然提醒后两边才改正 发布版首答 2/2,均定位到正确的旧版、正文节和末页并报告无单;其中一轮先试了当时不存在的节,收到错误后自行纠正
另一份稿件,正文节的位置相反。要求查补记前的原话及编号,且补记之后又调过样式 首答 2/2 正确,基线也能做成 发布版首答 2/2 同样给出正确的旧版、末页、用户原话和原编号;没有把这一题计为新增收益

为什么只查“最近的一张单”会答错。服务端旧记录中,最大的已验页号只代表哪些页曾留单。这里将一段已知原文首次或再次出现的编辑定位到修订,然后用目标修订的稿件、字体、版面和局部编辑分页。用实际位置查既有单据,未创建新预览或测量。能证明的是单据关联到哪个修订,既有系统允许事后补验,版本归属不能证明实际开单时刻。

如何重做。准备至少两节的长稿,在某节的第 1 页留单、在该节最后一页留空,然后追加一段独有文字,在新版本的末页留单。先用新增片段、正文节号和 page="last" 查询,应匹配追加前版并返回 no_recorded_review。再用新版本号查同一节的末页,应返回新版本单据。将追加片段删掉再加回,两个“加入前”可以有相反答案。测试还覆盖片段在初稿已有、无匹配、跨节重复、相邻修订持续保留、同节删除后重加、晚补检查单,以及超过两项的歧义选项。对长稿实际导出 ZIP 对照最后一页,并验证稿件收缩到一页后仍能找回旧末页。连续读取前后核对测量表和评语表,逐行相同。

成本。需要读取整节并经过真实引擎分页;已知数字页仍直接查询。本机两份两页稿各交替执行 7 次(含每次启动 stdio),发布版数值页中位数分别约 8.6 / 8.5 ms,相对定位末页约 195 / 201 ms。测试机当时还运行其他工作负载,未测大稿尾延迟。此项优化解决取证准确性,不能据返回字节推断节省计算时间。

重复引入和选错节的反例。同一句片段先加入、删掉、又放回。两个候选旧版本在正文末页分别无单、有单。最初遇歧义直接报错,2 个新会话都绕开错误各猜了一个时点。只列两个版本后,首答都能识别歧义,但其中一个经用户澄清后误把“补记所在节”当成“正文待查节”;用户再指出后才纠正。发布版区分定位版本的短语和待验正文;多节稿使用新的相对定位或末页查询且遗漏节号时,提供最多 4 条截短的节内容供选择。重复添加时列出两个时间选项及当版正文线索,允许分别核对或请用户确认,结果中没有可供误引的候选单号。最后重新在完整、只读两组各跑 1 次,两个新会话都正确列出了两种情况,没有擅自选一个时点。

发布版三种情形、两套工具共 6 轮,前后测量表和评语表逐行一致。按已存单据判定位置和归属时 6/6 首答正确。仍有一条答复将“查无已存单据”说成“未验过”;软件能证明的是没有存档,无法证明用户从未在线下看过。样本集中在已知反例和针对性变体,不估算总体准确率。输入使用保存原文的字面片段;口述措辞不一致时需要先查正文,或让用户说明所指的修改。

发布树已经通过 fmt、workspace 严格 Clippy、真实 SDK/stdio 全流程及专门针对历史定位的 SDK 断言。

@sourcery-ai

sourcery-ai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Add a pagination-only count API that runs the normal page layout pass so historical last-page lookup can use the selected revision’s actual page count.

  • crates/handwriting-core/src/render.rs L295-299

API

Extend the review-read input with a numeric-or-last page selector and an optional Markdown fragment for resolving the revision before an addition.

  • crates/panache-mcp/src/inputs.rs L145-157, L162-167

Uses of the API

Route review reads through the new historical lookup flow, paginate the requested section for last-page queries, and return the matching stored receipt with version and ambiguity context.

  • crates/panache-mcp/src/main.rs L69-167, L391-400 (+4 small edits)

Expose section page counting through the engine using the normal render request while accounting for projected-paper backgrounds.

  • crates/panache-mcp/src/engine.rs L247-265

Implementation

Resolve section choices for ambiguous historical reads and detect text introduction transitions, rejecting missing, repeated, or first-revision matches with actionable candidate guidance.

  • crates/panache-mcp/src/drafts.rs L59-73, L327-424

Documentation

Document literal-fragment and last-page historical lookup, including section selection, ambiguity handling, and the distinction between a review’s revision and its creation time.

  • crates/panache-mcp/README.md L75-77

Record the new MCP historical review lookup capability in the unreleased changelog.

  • CHANGELOG.md L5-6

Tests

Add regression coverage for historical last-page resolution, introduction ambiguity, required section selection, read-only behavior, and preservation of numeric-page queries.

  • crates/panache-mcp/tests/review_comparison.py L169-240, L245

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 added a commit that referenced this pull request Nov 24, 2026
## 整合范围

在当前 `main`(`f877788`)上整合本轮六个 MCP draft,保留已有接口和测试。这是统一的审阅与 CI 入口。原 PR
保留实验讨论和迭代记录。

| 原 PR | 纳入的行为 | 已核对的来源提交 |
| --- | --- | --- |
| #18 | 导出给出所查版本缺少整页复盘的节号与节内页码 | `f2bd1862b15b` |
| #19 | 翻过末页时按同一历史快照提示下一节或终点 | `b362df54e21f` |
| #20 | 按版本和页码只读找回原单,区分用户和模型反馈 | `4328a5ef9e85` |
| #21 | 查档轮次的客户端工具清单与转发示例 | `f8afa6e0e9f8` |
| #22 | 按补记前的版本和正文实际末页定位,重复引入时列出选项 | `08089ac7f08b` |
| #23 | 从作业/实验报告的日常说法找到笔迹扰动、偶发划改及同页验证 | `2fcdd17db13f` |

## 跨功能验证

合并相邻的检查单读取与导出覆盖查询,保留两套断言。客户端指南使用整合后提供的 `before_text` /
`page="last"`,从导出缺页回查时固定导出版本。缺单回执也说明现有档案对线下查看行为的证明边界。

新增 stdio
回归:当前版导出提示某页缺单,按导出版本查该页为空,按补记前的版本查同一节末页却有原单;再次导出的缺单清单应完全相同。本地及弱模型组合实验结果见本
PR 评论。

原有 #18–#23 在此 PR 合并前继续保持打开。

## Summary by Sourcery

整合 MCP 历史查单、缺页导出、多节导航、笔迹调节与复盘保护能力。

New Features:
- 扩展 MCP 历史复盘查询,可按稿件版本、节号和页码读取已有整页记录,并支持按新增原文定位补记前版本及指定节末页。
- 导出结果新增按打印顺序报告缺少整页复盘的节内页码,并完善跨节翻页提示。
- 新增笔迹松散度和偶发划改调节能力,并支持直接或按控件组提交调参。

Bug Fixes:
- 修正历史检查单无法区分受检版本与首次入档版本的问题,并为旧记录保留未知状态。
- 修正无效页码和多节稿件查询的错误提示,使其提供实际页数及后续节信息。

Enhancements:
- 支持在保留既有复盘记录的模式下改稿、查看成图和导出,同时阻止新增检查单与评语。
- 完善检查单查询、导出回查、客户端工具选择和 MCP 使用指引,并保持只读查询不产生新记录。

Documentation:
- 补充历史查单、缺页回查、保留复盘记录、笔迹调节及只读客户端调用的用户指南。

Tests:
- 增加历史版本末页定位、重复原文消歧、缺单导出一致性、页码提示、笔迹调节和保留复盘模式的 MCP 回归覆盖。

Chores:
- 为复盘记录增加首次入档版本的数据库字段及兼容旧数据的迁移处理。
@SXP-Simon SXP-Simon closed this Nov 24, 2026
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