Skip to content

test(crates/panache-mcp): 添加只读工具转发轨迹回归 - #30

Closed
SXP-Simon wants to merge 1 commit into
mainfrom
test/mcp-review-trajectory
Closed

SXP-Simon wants to merge 1 commit into
mainfrom
test/mcp-review-trajectory

Conversation

@SXP-Simon

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

Copy link
Copy Markdown
Owner

目的

把 #21/#24 提出的「只读轮次必须限制实际转发」变成一个可复跑的本地证据入口。不能只看回答或 SQLite 计数:同一页的多次复查可能去重,工具错误也可能看起来像成功拦截;两者应该分开验。

仅增加 crates/panache-mcp/tests/trajectory_check.py。不改服务、默认权限、业务文件、文案或任何 CI 配置。这是固定动作回放,不是测真实模型误选概率。真实模型另由独立对照记录。

实测

固定合成稿和相同动作预算,绝不使用用户文档。从同一份 SQLite 备份复制两个临时 MCP home,使用实际 Rust MCP 二进制、校验过的 Markdown worker 和 Python MCP SDK 1.29.0。

序列 主机只读臂实际转发 / 主机阻挡 / 新复盘 放行对照实际转发 / 主机阻挡 / 新复盘
读 → 复查 → 读 2 / 1 / 0 3 / 0 / 1
读 → 读 2 / 0 / 0 2 / 0 / 0
复查 → 同页复查 → 读 1 / 2 / 0 3 / 0 / 1

阅读、转发、失败和实际 SQLite 状态分别记录;检查回执中的 ID 与实存行一致。记录完整工具目录及哈希,已知进程随机的 schema seed default 另记原值,不掩盖其他属性变化。独立损坏字体反例记录为工具执行错误,而非“主机阻挡”,无新记录,验证按预期退出 1。

复跑

cargo build --locked -p panache-mcp
# 使用本地真实字体和 Markdown worker;必要时显式设置相应环境变量
python3 crates/panache-mcp/tests/trajectory_check.py target/debug/panache-mcp \
  read_section preview_handwriting read_section > trajectory.json

验收的是两臂的预期区别;开集臂故意允许写复盘,是实验对照,不是部署建议。只检查始末 SQLite,不能推断轮中写后撤销。草稿,不加标签,不触发 Actions。

Summary by Sourcery

Provide a reproducible local regression harness for verifying read-only tool forwarding and persisted review outcomes.

New Features:

  • Add a reproducible fixed-action trajectory replay entry point that compares read-only and open tool-dispatch behavior against SQLite state.

Enhancements:

  • Capture tool catalogs, environment metadata, binary hashes, action outcomes, receipts, and database snapshots as machine-readable evidence.
  • Validate host blocking, tool success, receipt-to-database consistency, review-row expectations, and preservation of unrelated database state.

Documentation:

  • Document local execution, action budgets, and the distinction between host blocking and tool errors in the replay script.

Tests:

  • Add regression coverage for read-only forwarding trajectories using isolated SQLite copies and the actual MCP binary.

背景:历史查单在只读轮次不能生成新记录;仅看最终答案或缓存后的行数,可能漏掉模型尝试的未授权写入。

解决手段:用实际 MCP stdio 复放同一批固定调用至同稿两份隔离 SQLite,一臂限制工具转发,另一臂放行,输出实际回执、动作分类和始末状态。

收益:真实混合轨迹主机限制为 0 条新增、放行为 1 条;重试同页时两次写能力调用只产生 1 条,分别验证调用和终态才能识别差异。
@sourcery-ai

sourcery-ai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Reviewer's Guide

Tests

新增固定动作回放脚本,以隔离的数据库副本对比只读门控臂与放行对照臂,并核对工具目录、转发结果及 SQLite 状态。

  • crates/panache-mcp/tests/trajectory_check.py L1-197

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

复跑证据与一个易漏的反例

在 e1e2546a 的真实 Panache 构建上独立跑了三组,Rust 1.94.1、Python MCP 1.29.0、固定 seed 42、正版发布包校验后的 Markdown worker。两臂用 SQLite backup 从同一份合成稿开始,只比较 MCP real stdio,所有记录均为合成数据。

  • 混合组:read_section preview_handwriting read_section。预算 3,受限臂转发 2/阻挡 1,复盘保持 0,末次仍 no_recorded_review;开放臂转发 3,0→1,末次回执 ID 与数据库一致。
  • 纯读组:read_section read_section。两臂转发 2,均保持 0,说明比较本身不会生成检查单。
  • 重复组:preview_handwriting preview_handwriting read_section。开放臂确实转发了两次可写能力调用,但同页去重,最后仍只有 1 条;受限臂明确记录其 2 次尝试均被主机拒绝。只看行数会漏掉一次尝试。
  • 错误路径:把测试所选字体换成损坏夹具后,开放臂的调用返回 invalid_font,没有新增记录,但验证仍以非零退出。没有写入不等于主机正确拦截。

运行 cargo build --locked -p panache-mcp 后,设置 PANACHE_FONT_DIR 与正式 PANACHE_MARKDOWN_WORKER,执行 python3 crates/panache-mcp/tests/trajectory_check.py target/debug/panache-mcp <上列动作>。JSON 保留原始目录、单列的随机种子注解、始末摘要、真实事件和检查项,不含照片内容。这不是线上权限配置,也不是模型准确率基准。

SXP-Simon added a commit that referenced this pull request Nov 25, 2026
## 评审收口
把 [#30](#30)
的只读转发回归和本草稿的同版字形回归放在一个测试候选中。保留两个独立运行入口和各自的断言,仅让现有 `mcp_client.py` 共用临时
home、SDK stdio 启停及 SQLite 备份。相对两条原草稿简单叠加净减 12 行;没有新共用文件或生产代码改动。#30
仍开放留证,审查时不要把其重复测试再次合并进来。

## 真 MCP 验证
- 只读轨迹:受限臂转发 2/3 个动作、拦下会建单的预览,SQLite 逻辑数据不变;开放对照转发 3/3、实存 1 条检查单且与回执匹配。
- 同版布局:9/9。五例宿主未发包,一例实发后 Rust
以旧版拒绝,三例实际写入;核对着色和原位移。即使确实观察到当前布局,也仍有故意选错字后改到「明」的反例,不能把同版 ID 当用户意图或像素保护。
- 独立云用精确组合分别跑两原案及两候选,四个命令正常退出。根用同 Git 树重构,两个针对性 SDK 命令及以已核对 e1e2546
基线二进制执行的完整 stdio smoke 通过。这是 Linux 合成稿的固定动作,不是模型错选率;不改服务器、默认客户端权限或 CI。

## 复跑
```sh
cargo build --locked --release -p panache-mcp
# 环境须提供项目已有字体和 Markdown worker
python3 crates/panache-mcp/tests/trajectory_check.py target/release/panache-mcp \
  read_section preview_handwriting read_section
python3 crates/panache-mcp/tests/layout_witness_check.py target/release/panache-mcp
```

仅草稿,无标签、无 CI、未合并。以下为先前字形范围的自动摘要,保留原文。

## Summary by Sourcery

Add local MCP integration evidence for replaying glyph edits and review
actions against isolated draft copies while validating layout provenance
and database outcomes.

Enhancements:
- Add test-only MCP replay harnesses that verify layout witnesses are
bound to the observed draft revision, section, page, and glyph subset
before edits are forwarded.
- Add isolated SQLite cloning and inspection helpers for deterministic
comparison of server state across replay scenarios.

Tests:
- Add local integration coverage for stale, partial, mismatched,
combined, and unguarded glyph-layout evidence, including
revision-conflict behavior.
- Add trajectory replay coverage for host-blocked versus forwarded
review actions and preservation of non-review database state.
@SXP-Simon SXP-Simon closed this Nov 25, 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