Skip to content

[OPS-PTC P4] 清除指向已隐藏官方文件工具的系统指引 #983

Closed

Description

@Thatgfsj

P4 · 清除指向已隐藏官方文件工具的系统指引

总计划 #978,所属工作流 #978。

问题:工具从 tools:sdk 消失后,官方 tool:grep 段仍可能写着使用 grep 或 read。在小模型看来这是仍可执行的命令。

前置条件:依赖 P3 的隐藏路径,先在 #961 上确认是否已覆盖。

从哪里读

  • src/publication/replacements.ts
  • src/publication/ptc.ts
  • test/mode-contract-audit.test.mjs

认领前记录当前 main SHA。以上为优先检查的范围,需要扩大写域时先说明文件与原因。

按顺序执行

  1. 同一 fixture 注册真实官方 read/glob/grep,在隐藏前后保存非空 section 的名字和正文。定位仍包含指令的 section,特别是 grep 对 read 的交叉引用。
  2. 按当前作用域的实际可用集合调整或移除失效的指令;复用受支持的宿主扩展点。
  3. 切回未隐藏或 Native 子作用域,重新装配,检查被保留的入口仍有正确说明。

验收清单

  • 隐藏三项后,SDK 和教学中不再教调用这三项;若只隐藏 read,grep 自身仍可保留,但“用 read 看命中”应有可执行替代。
  • 分别提供 SDK 字节差、其他 system 段差、外层 wire 差;不得把整段 SDK 当作额外请求再计一次。

范围边界与停手条件:若只能通过重写宿主共享 registry 或篡改其他插件文件解决,停在复现测试并向维护者说明扩展点限制。

验证与交付

先运行 npm run build;依赖 native worker 的测试先运行 npm run build:ptc。定向入口:node test/run.mjs mode-contract。确认过滤器命中目标套件,记录实际 pass / skip / fail。

认领模板:编号 / 当前 SHA / 目标文件 / 第一个失败样例。提交时贴修改前与修改后结果,以及撤掉改动后会失败的断言。已有 PR 请先在原讨论协作。行为及中英文文档同 PR。

Activity

  1. Thatgfsj commented on Nov 19, 2026

    @Thatgfsj
    CollaboratorAuthor

    983 / main@58f6e28 / src/publication/replacements.ts、test/ptc-guidance-cleanup.test.mjs(新增)、docs/native-output.md、docs/CHANGELOG.md / 第一个失败样例:挂真实 dsh-tool-fs/dsh-tool-fs-search 后 ops-ptc 隐藏 read/glob/grep,装配仍输出宿主 tool:read 段正文 "Use the read tool",tool:grep 仍教 "Use read on a matched file"——指向已隐藏名字的死指针

  2. Thatgfsj commented on Nov 19, 2026

    @Thatgfsj
    CollaboratorAuthor

    完成(Refs #961):清除指向已隐藏官方文件工具的系统指引。

    载体:补充 commit 1d15083(fix(ptc): retire guidance that names hidden official file tools)fast-forward 推到 Nicholas023/dsh-ops 的 fix-ptc-hide-official(PR #961 head 2fc5540 → 1d15083,未 force、未改写历史)。分支 p4-guidance-cleanup。

    修改前结果(红,基线 2fc5540,真实 dsh-tool-fs/-fs-search fixture):

    • 全隐藏后装配仍含 tool:read 全文 "Use the read tool — not shell commands like cat…"(断言 tool:read guidance must not reach a scope that hides it 失败);
    • 部分隐藏(dynamicTools:false,read 隐藏、grep 保留)tool:grep 仍教 "Use read on a matched file",且无可执行替代断言失败;
    • 字节差断言失败:隐藏态三段宿主指引仍有 338 B。
      首跑 3 fail / 6。

    修改后(绿):ptc-guidance-cleanup 6/6。实现位于 src/publication/replacements.ts:隐藏判定提取为 shadow when 与装配共用的同一 hiddenByPtc;在受支持的 system-prompt/assemble 瀑布中,PTC 呈现下移除已隐藏名字的宿主 tool:* 段;保留工具的段含死指针时整段移除并补一行指名可执行 OPS 替代(dsh-ops:replaced-official:<mode>);不含死指针的保留段(tool:glob、tool:write、tool:edit)原样存活。撤下模式行后宿主文案逐字恢复(含 grep 对 read 的交叉引用一并回归);hideOfficialTools:false 与 Native 子作用域不受影响。不改宿主注册表、不做字符串替换;#866 的 Native 侧保持开放。

    撤掉改动后会失败的断言:tool:read guidance must not reach a scope that hides it、the grep cross-reference to the hidden read must not survive verbatim、the hidden read keeps an executable alternative in the assembly、the hidden names contribute no provider guidance bytes。

    定向验证(Linux,DSH_OPS_WORKER_BIN=runtime/linux-x64/dsh-ops-worker,sha256 前缀 2b5f988d;先 npm run build 重建 lib):ptc-guidance-cleanup 6/6;回归 ptc-hide-official 13、native-guidance 2、replacements-admission 11、replace-concurrency 2、replace-size 3、mode-contract-audit 4、modes 12、prompt-budget 1 全绿;check:size 通过(823 文件,最长 930 行)。release-tar-modes 在未改动基线同样失败(本机 npm bundled tar 缺失,环境问题,与本次无关)。

    分项字节差(同一 fixture 隐藏 − 未隐藏,只报相对差):SDK −2,011 B(与 #978 记录一致);宿主指引段 tool:read/tool:glob/tool:grep −338 B;其他 system 段 0 B;外层 wire 0 B(两种状态都只有 run_code)。

    文档:docs/native-output.md 与 docs/Native输出.md 的 #866 依赖段补记 PTC 侧收口及边界;docs/CHANGELOG.md ## [Unreleased] 增双语条目。

  3. Thatgfsj commented on Nov 20, 2026

    @Thatgfsj
    CollaboratorAuthor

    已由 #1033 合入 main 交付(18 张卡并集,见 PR 描述与 docs/CHANGELOG.md 的 Unreleased 条目)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions