Skip to content

feat(crates/panache-mcp): 按版本和页码只读找回整页检查单 - #20

Closed
SXP-Simon wants to merge 1 commit into
mainfrom
feat/mcp-review-receipt
Closed

SXP-Simon wants to merge 1 commit into
mainfrom
feat/mcp-review-receipt

Conversation

@SXP-Simon

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

Copy link
Copy Markdown
Owner

用户遇到的问题

“这张当时验过吗?”既可能问当前稿,也可能问修改前的某一版。原有的按编号读取要求用户或模型先找出编号。跨版本历史中,相邻版本同一页的评语很像。另一个看似合适的入口是整页预览,但调用它会实际记录一次检查。

变更

在已有的 read_section(view="review") 上增加按页查单。传 draft_id、section 和 page,省略 revision 查当前版,提供版本号查历史。复用逐页比较所用的 SQLite 查询,以同一位置最后存入的检查单为准。返回原编号、测量、带来源的反馈,同时标明所查版本和当前版本。该位置没有记录时返回 no_recorded_review,无需调用渲染器。该结果只说明缺少单据,无法据此判断页是否存在。

已有按编号查询仍可用。按编号读到其他版本时,附上去所查版本核对该页的提示。启动说明和工具说明明确区分查旧记录与创建新测量。无新工具、表或渲染依赖。

验证与来源

Rust 单元和真实 MCP SDK/stdio 测试覆盖同页多次测量、旧数据、空记录、版本隔离、反馈来源及不兼容参数。六个独立的弱模型对照场景及仍失败的例子见本 PR 的实验评论。这个变更可独立于 #18 和 #19 审阅。

取材于 OceanBase PowerContext Handoff Report 的按范围只读查询及显式空结果。

Summary by Sourcery

Enable read-only retrieval of stored full-page reviews by draft version, section, and page without invoking the renderer.

New Features:

  • Support read-only retrieval of the latest recorded full-page review for a specified draft revision, section, and page, including measurements, review ID, attributed feedback, and the current draft revision.
  • Return an explicit no_recorded_review result when no review exists without rendering or creating a new measurement.

Bug Fixes:

  • Clarify historical review lookups by warning when a review ID belongs to a different revision and directing callers to verify the requested page in the target revision.

Enhancements:

  • Reuse page-based review lookup behavior across direct reads and revision comparisons while preserving version isolation.
  • Update MCP tool guidance and README documentation to distinguish reading existing reviews from rendering and recording new inspections.

Documentation:

  • Document version-, section-, and page-based retrieval of stored full-page reviews and its explicit empty-result behavior.

Tests:

  • Add Rust and MCP integration coverage for repeated measurements, historical revisions, missing records, version isolation, feedback attribution, and invalid parameter combinations.

Chores:

  • Record the new page-based review lookup capability in the changelog.

背景:回查纸张的旧记录时,客户端需要先从跨版本历史猜检查单号,也容易在整页预览中生成新的测量。

解决手段:在 read_section 的 review 视图复用逐页比较的查询,精确匹配稿件、版本、节号和页码。回执标明所查版本、当前版本和检查单号;没有记录时返回明确状态。提示客户端区分查单与新建检查。

收益:调用方可以直接核对指定页的原测量和评语来源,按页查空也无需渲染,已知编号的客户端仍可精确读取原记录。

Copy link
Copy Markdown
Owner Author

实验复核(仅汇总)

对照为 3150e52,候选为 4328a5e。每种情况在两个构建各用一个新 gpt-5.6-luna / low 会话,在同样的初始数据库副本上运行。稿件、跨版本干扰记录、用户与模型两类反馈均通过正常 MCP 接口建立。模型只得到自然语言任务、工具清单、schema 和真实 stdio 结果。出现明显错误时,模拟用户用日常语言提醒。评估方再用数据库、打印产物和逐次调用记录核对。以下为整段对话的业务调用数,含纠正后的调用。结果字节包括图片 base64,不含握手与工具发现。

测试条件 调用数,对照→候选 返回字节,对照→候选 候选结果
A 当前版本有两种来源的反馈,要求原测量、用户原话和编号 7→3 1,236,587→4,492 三项正确,预览 1→0
B 旧版有单,当前版同页无单 4→4 10,574→4,590 区分两版;额外附了旧版记录
C 根据后来增加的内容查前一版 8→4 2,876,619→19,473 原编号和原话正确,预览 3→0
D 追查评语来源并打印旧稿 7→5 976,566→8,909 正确归因为模型,导出的 PDF 与留存旧稿字节相同;按 144 DPI 渲染,像素差也为零
E 当前版只有局部检查,要求只查旧单 4→4 1,391,470→1,390,539 两边各新增 1 张整页单,失败
F 后来才有记录,追问更早的版本 5→8 8,992→13,076 候选首次及用户纠正后均将后来的单据归到旧版;独立复跑一次则答对

服务端复现。准备两节两页的测试稿:v2 检查第 2 节第 2 页并写一条测试反馈;调墨色得到 v3,只检查第 2 节第 1 页。连续两次按 v3、第 2 节、第 2 页调用 read_section(view="review"),均得到 status=no_recorded_review 和空编号。将版本换成 v2,可取回原测量和带来源的反馈。六个测试位置各查询两遍,正例与原 SQLite 记录逐字段一致,负例均为空,两张记录表前后逐行相同。提交内的测试另覆盖旧数据、同位置多次测量和不兼容参数。

反复失败的地方。先实现按页查单,再改工具描述,随后在回执开头显示版本、节页与编号,并在按编号查到其他版本时提示如何重查。E 另做两对新会话,合计对照 3/3、候选 3/3 都新增了整页单。判定失败看实际写入,即使模型在被纠正后能解释先后顺序也计失败。六类情形的样本量不能估算总体成功率。

PowerContext 取舍。在 5eb3f92 复跑 Handoff Report 的 3 个 SQLite 测试,通过。它按所选 Scope 投影已提交的交接,缺失时明确给出空结果。Panache 把这个规则用在稿件版本和页的位置。Handoff Report
上游 Hermes 修复的合并前 8588278、合并后 7c07814,以真实 provider、上游 FakeClient、相同的两轮不同查询回放,准备请求 2→1,排队 1→0,返回的召回文本相同。当前 provider 另有 130 个本地测试通过。此处只观察请求次数,没有测量真实模型或服务端时延。上游 #2781
另一项开放评估中,上游报告 495/495 个父事实进入输入,但 6 个已接受 Unicode 输出各只保留 1/3 个要求逐字保留的片段,结论仍为 insufficient_evidence。因此这里分别检查最终答案中的来源与编号、工具副作用和文件字节。上游 #2541

本地通过 fmt、工作区严格 Clippy、Rust 工作区测试(178 通过,1 个既有忽略项)和实际 MCP SDK/stdio smoke。

@sourcery-ai

sourcery-ai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Add the latest draft revision to snapshots so page lookups can report the current version alongside the selected revision.

  • crates/panache-mcp/src/drafts.rs L47, L343

API

Extend the read input and MCP tool behavior to retrieve a page’s saved review by revision and to distinguish that lookup from reading by review ID or creating a new inspection.

  • crates/panache-mcp/src/inputs.rs L148-151
  • crates/panache-mcp/src/main.rs L69-110, L339-342 (+4 small edits)

Implementation

Reuse the per-page observation query for direct lookups and comparisons, returning an explicit empty result when no review exists at the requested position.

  • crates/panache-mcp/src/drafts/observations.rs L59-76, L105-117 (+3 small edits)

Documentation

Document the new read-only page lookup, its empty-result semantics, and how it differs from generating a new inspection.

  • CHANGELOG.md L5-6
  • crates/panache-mcp/README.md L75-76

Tests

Exercise page lookup through the MCP SDK and stdio, including empty results, revision isolation, ID compatibility, and invalid parameter combinations.

  • crates/panache-mcp/tests/review_comparison.py L281-288
  • crates/panache-mcp/tests/smoke.py L407-420

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