Skip to content

feat: MCP 按节找回用户签样与版本依据 - #16

Merged
SXP-Simon merged 5 commits into
mainfrom
feat/mcp-trajectory-feedback
Nov 23, 2026
Merged

SXP-Simon merged 5 commits into
mainfrom
feat/mcp-trajectory-feedback

Conversation

@SXP-Simon

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

Copy link
Copy Markdown
Owner

接手续稿时,找回用户签过的那一版

延续 #14 的稿件轨迹与复盘实验。原来的轨迹能保存用户原话、模型观察与页面测量,但传入 section 会被静默忽略。查“第 2 节的用户原话”需要翻阅全稿事件。字段说明还给出了正文的 4000 字符上限,而轨迹每次最多读 50 条事件。

{"draft_id":"…","view":"trajectory","section":2,"feedback_origin":"user_quote","limit":1}

这个 read_section 请求返回关联版本最高的一条匹配原话。事件的 details.text、revision 和 review_id 足以回答“用户当时说了什么”。需要看当时的测量或同一复盘的其他评语时,再按 ID 取详情。事后补在旧版上的话仍归在旧版。

两个条件都可省略。原来不传筛选条件的请求仍返回全稿轨迹。显式传 section 现在只看归属该节的事件,全稿调参记录在全稿视图中查看。offset、limit 和 next_offset 按筛选后的事件计数。沿用现有数据库和工具集。

并发分页。 在 评审修复 中,首页同时读取稿件版本、复盘序号和评语序号边界;有后续页时返回 next_cursor,下一次传给同稿 read_section(view="trajectory", cursor=…)。用两个独立 stdio 客户端验证过:首页之后补录同版本原话,重启读取端后游标仍精确续读原集合,重新查询则读到补录内容。旧客户端仍可用数字 offset 跳页;此方式读取实时集合。

较弱模型盲测

基线为 18e09ec。两份留出稿分别有 73 和 72 条合成历史事件,包含旧用户原话、较新但意见相反的模型观察、其他节的用户原话。每题要求返回目标节中关联版本最高的用户原文、版本和复盘 ID,还要核实另一节是否有用户原话。后者在这两题中均为空。通过受限 CLI 调用真实 stdio 服务,向模型提供了 read_section 入口和 schema,可在客户端解析返回值。模型看不到源码和答案。两个版本用独立、无前文的会话,同一会话做两题,Luna 和 Terra 的题序相反。

模型(low,两题合计) 完全答对,基线 → 加筛选 业务调用 错误调用 工具响应字节
GPT-6 Luna 2/2 → 2/2 6 → 6 1 → 0 106,023 → 7,538
GPT-6.1 Terra 2/2 → 2/2 7 → 6 1 → 0 110,192 → 7,538

基线的两次失败分别尝试了 limit=4000 和 100。每个业务响应按完整 MCP result(含文本、结构化结果或错误)重编码为紧凑 UTF-8 JSON 计量。表中排除了握手、工具发现与客户端加工。这轮盲测的工具数仍为 13 个,SDK 测得完整清单从 19,161 增至 19,608 字节。后续并发分页修复增加了可选的游标字段,工具清单现为 19,762 字节。这里测的是传回多少数据,没有测模型 token、延迟或费用。

从一次多余的调用再迭代

加入筛选后,两个模型在上面两题中都再次读取了整份复盘核实原文。于是只改工具描述,标明原话具体在哪个字段。再用新会话和一份 79 事件的留出稿重试,这次另一节确实有用户原话,目标也换了版本。Luna 从 3 次调用(4,226 字节)降到 2 次(1,874 字节),Terra 从 4 次(6,578 字节)降到 2 次(1,874 字节)。四次均答对。这一题各配置仅跑一次,足以说明这条路径可行,仍无法估计总体成功率。

从签样到两页 PDF

另给一位无前文的 Luna 一份真实渲染的两节合成手稿,只告诉它当前看不到字,要求按第一节签样恢复整稿、保留文字和位置、核对后导出。模型在加入筛选的版本上找到 v3 的签样,从 v5 的零透明度恢复签样的墨色和 81% 不透明度。一次写入得到 v6,导出时 2/2 页已有复查证据。两页归档像素摘要分别匹配签样,用 MuPDF 独立栅格化签样和交付 PDF 后,两页尺寸与 RGB 像素也分别一致。

开放任务耗费 20 次业务调用,其中 2 次调参查询失败。模型先读了全稿轨迹,也曾猜测不存在的 group=style。只在该版本跑了这一次,不能从定向查询推断完整制稿的提速。下一项值得单测的是模型能否直接发现正确的墨迹参数组。

复查与发布范围

  • 真实 stdio 回归覆盖双节双来源、模型和用户意见相反、筛选后翻页、历史截止、空结果和非法参数。Linux 本地用 Rust 1.94.1 验证格式、Clippy、工作区测试及完整 Python MCP SDK smoke。
  • 可在仓库的 MCP 验证入口 跑 smoke;新增用例使用实际写入、渲染和归档的记录。盲测的长历史则直接在 SQLite 写入合成数据,供可重复的读取对照。
  • 变更限于 MCP、回归、用法说明与未发布日志。PR 走现有代码检查;版本号、标签、打包脚本和发布工作流均无变动。

评估方法借鉴 MCP-Atlas 的逐项事实评分、DynamicMCPBench 的成品状态验收,以及 GEPA 用调用轨迹提出改动并在新题上检验的思路。这里实际完成了一轮由评测驱动的接口说明改进。

Summary by Sourcery

Improve续稿 workflow by making section-specific user feedback easy to recover through stable, filterable MCP trajectory reads while refining paper settings behavior.

New Features:

  • Enable MCP trajectory queries to filter history by section and feedback origin, making it possible to directly retrieve version-associated user quotes and review IDs.
  • Add cursor-based trajectory pagination that preserves the query snapshot and filters while retaining offset pagination compatibility.

Bug Fixes:

  • Keep paper camera settings visible only when a background paper is uploaded and preserve settings-field scroll position while expanding or collapsing controls.

Documentation:

  • Document filtered trajectory queries, cursor pagination, snapshot behavior, and the updated MCP workflow.

Tests:

  • Add mobile workbench coverage for conditional paper-camera settings, scrolling, editing, and background removal.
  • Add MCP regression coverage for filtered history, pagination, historical revisions, cursor validation, and concurrent backfilled feedback.

Chores:

  • Record the MCP and workbench changes in the unreleased changelog.

背景:接手续稿时,客户端需要翻过其他节的测量和模型意见才能定位用户签样,轨迹的分页说明也沿用了正文字数。

解决手段:在轨迹分页前按节与署名来源筛选,说明原话所在字段、关联版本与分页边界,并通过真实 stdio 回归验证。

收益:客户端可以直接找回目标节用户的原话和复盘 ID,也能确认是否存在匹配记录。
@sourcery-ai

sourcery-ai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

扩展 Read 与反馈来源类型以公开轨迹筛选和游标参数,并更新 read_section 的校验、分派及工具说明。

  • crates/panache-mcp/src/inputs.rs L150-153, L159-163, L257-265 (+1 small edits)
  • crates/panache-mcp/src/main.rs L396-409, L421 (removed lines)

Implementation

将轨迹查询拆到独立模块,实现按节和来源筛选、快照边界记录及游标续读,并在反馈写入时使用稳定的来源字符串。

  • crates/panache-mcp/src/drafts.rs L2, L408 (removed lines)
  • crates/panache-mcp/src/drafts/observations.rs L157, L171
  • crates/panache-mcp/src/drafts/trajectory.rs L1-126

UI

仅在存在底图时显示底纸拍摄设备,并用页面存储键保留各输入框的滚动位置。

  • app/lib/widgets/workbench_settings.dart L98-99, L427

Documentation

更新未发布日志和 MCP 用法说明,解释筛选结果、关联字段及游标分页行为。

  • CHANGELOG.md L5-8
  • crates/panache-mcp/README.md L105, L119-120

Tests

覆盖不同屏宽下底图设备栏的显示、输入框滚动、编辑及移除流程。

  • app/test/mobile_workbench_test.dart L284-351, L361

验证反馈来源序列化调整后的旧轨迹读取兼容性。

  • crates/panache-mcp/src/drafts/observations.rs L243-245

通过真实 MCP 调用检查筛选、排序、历史版本、快照分页、补录事件和非法游标行为。

  • crates/panache-mcp/tests/review_comparison.py L104-168, L313

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="crates/panache-mcp/src/drafts.rs" line_range="433" />
<code_context>
                    COALESCE(e.evidence,n.details,'{}'),e.review_id,e.origin
             FROM events e LEFT JOIN edit_notes n ON n.draft=?1 AND n.revision=e.revision
-            WHERE e.revision<=?2
+            WHERE e.revision<=?2 AND (?5 IS NULL OR e.section=?5) AND (?6 IS NULL OR e.origin=?6)
             ORDER BY e.revision DESC,(e.action='review_feedback') DESC,(e.action='page_review') DESC,e.seq DESC,e.section,e.page
             LIMIT ?3 OFFSET ?4")?;
</code_context>
<issue_to_address>
**History pages duplicate or skip events**

When another request commits a matching annotation between page requests, `trajectory` reruns the ordered query with the old numeric offset against the changed event set, so shifted page boundaries return an event twice or skip one.

Paginate over a stable event snapshot or cursor rather than reusing a numeric offset against a changing result set.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: crates/panache-mcp/src/drafts.rs:433


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread crates/panache-mcp/src/drafts.rs Resolved
背景:两次轨迹读取之间补录旧版反馈时,数字偏移会在已变化的历史中重复返回事件。

解决手段:首次读取时一起记录稿件版本和归档序号边界,通过游标续读同一批事件,并验证跨页补评、补做复盘和改稿的行为。

收益:客户端可以在其他会话编辑或补评时逐页取完原有记录,新查询也能立即看到新增内容。

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

背景:默认纸张也显示底纸拍摄设备,展开后设备输入框与折叠栏共用页面存储位置。

解决手段:按工作台实际底图显示设备栏,为每个输入框单独保存滚动位置,并在窄屏和宽屏工作台验证上传前后及移除后的行为。

收益:预设纸张的参数页可以直接查看页边距,使用照片底纸时仍能填写拍摄信息并继续向下滚动。
背景:窄屏和宽屏回归在滚动后立即命中测试,会沿用上一帧的控件位置。

解决手段:等待工作台完成布局,点选菜单里的纸张标签,并直接检查末行输入框。

收益:滚动到底和移除底图的断言反映用户实际可以操作的位置。
背景:宽屏用例在界面检查结束时仍有一次稿件保存计时器。

解决手段:移除底图后推进测试时钟到现有保存延迟,再检查最终界面。

收益:回归覆盖完整的移除流程并正常结束。

Copy link
Copy Markdown
Owner Author

小修:纸张设置里的「底纸拍摄设备」

现在使用默认纸张、横线纸或方格纸时,参数页直接显示纸张尺寸和页边距。上传照片底纸后才出现「底纸拍摄设备」,移除照片后该项随即隐藏。

排查时确认,移动端、桌面端和 Web 都使用同一个 Flutter 纸张设置组件。展开设备栏时,原实现会让折叠栏的展开标记和输入框的滚动位置写到同一处,导致输入框读到错误类型,表现为灰块、滚动异常。这次只调整显示条件,并为设备输入框分别保存滚动位置。实现提交

已在 CI 的 375 px 窄屏和 1440 px 宽屏工作台回归中验证:无底图时能滚到最后一个页边距;加入照片后能展开、填写 ISO 并继续滚到底;移除照片后设备栏消失。Flutter 静态分析和完整测试均已通过。这里验证的是共享组件的两种布局,未逐台做真机验收。CI 记录

@SXP-Simon
SXP-Simon merged commit cf932d3 into main Nov 23, 2026
16 of 20 checks 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