Skip to content

debugging: 用 Failure-class Benchmark 验证按需 DAP 是否优于 Logs 与 Tests #168

Open

Description

@tt-a1i

结论

OMP 的 DAP debugger 是 OpenPI 当前没有的高阶功能:模型可以 launch/attach、断点、step、读取 stack/scope/variables、evaluate,甚至使用 instruction/data breakpoint 和 memory 操作。

这对难以靠日志与测试定位的 runtime bug 可能有显著价值,但完整 DAP Runtime 的 adapter、进程树、暂停状态和权限面很重。OpenPI 应先按 failure class 做 paired benchmark,确定哪些问题真正需要 debugger,再决定它属于 Pi core、独立 package 还是按需 OpenPI capability。

这是 #45 的具体拆分。

对比证据

固定审查点:

OMP DAP 工具覆盖 launch/attach、source/function/instruction/data breakpoints、continue/step/pause、stack/scopes/variables/evaluate、memory/disassemble/modules/custom request 等操作。OMP debug surface

读状态与执行动作采用不同 approval;tool discoverable,debug setting 默认开启。OMP output/approval

Runtime 管理一个 root DAP tree,处理 adapter spawn/socket、child debug session、breakpoint 同步、stop event、timeout 与完整 tree terminate。OMP lifecycle

OMP 内置多种 adapter 定义并自动选择,但只使用当前可解析的命令。OMP adapters

OpenPI 当前普通路径依赖 Pi read/bash/edit/write 和项目测试,没有 debugger capability。OpenPI native path

需要回答的问题

  1. 哪些 failure class 用 debugger 明显优于日志、测试、临时 instrumentation?
  2. 模型能否稳定维护 stopped thread/frame/scope identity,还是容易对 stale id 操作?
  3. launch/attach、read state、evaluate、memory write、custom request 应如何分级权限?
  4. debuggee、adapter、child process tree 由哪个 Session/cwd 拥有?
  5. pause/step timeout 后,目标是 running、stopped 还是 uncertain,如何证明?
  6. Session switch、cancel、shutdown 时如何清理,不误杀用户已有进程?
  7. attach 到现有 PID 是否应完全排除首版?
  8. debugger 是否应是 Skill 驱动的临时外部工具,而非 OpenPI package-owned surface?

建议 benchmark

选择可复现的 failure classes:

  • 并发竞态或事件顺序;
  • 只在运行时状态出现的错误;
  • 多层调用栈数据污染;
  • child process 问题;
  • 普通单元测试已能清楚定位的对照组。

比较:

  • A:tests + logs + temporary instrumentation
  • B:同模型 + 最小 read-oriented DAP
  • C:同模型 + full stepping/evaluate

记录成功率、定位时间、tool calls、tokens、代码污染、stale-state 操作、adapter 启动失败、取消/清理和不同模型能力曲线。

最小原型边界

只有 B 对特定 failure class 有稳定收益后:

  • 只接已安装 adapter;
  • 明确 intent 后加载;
  • 首版 launch only,不 attach 用户进程;
  • 首版只开放 threads/stack/scopes/variables/output/continue/terminate;
  • evaluate、memory write、custom request 后置;
  • 单 Session 单 root tree;
  • 所有状态带 session/generation/thread/frame identity;
  • terminate 给出完整或 uncertain receipt。

验收标准

  • failure-class paired benchmark
  • 证明 debugger 不只是“看起来高级”
  • read/exec/memory mutation 权限分层
  • stale thread/frame/scope fail closed
  • timeout/cancel/shutdown 后状态可证明
  • 不误杀 pre-existing process
  • 普通 turn 零 schema 与进程税
  • 明确最终归属或不采用

Activity

  1. added
    enhancement
    on Aug 25, 2026
  2. 627150795 commented on Aug 29, 2026

    @627150795
    Contributor

    I am taking a focused research slice: turn the proposed failure-class comparison of on-demand DAP versus logs/tests into a reproducible benchmark protocol. This pass will not add a debugger dependency, DAP runtime, or claim experimental results.

  3. 627150795 commented on Aug 29, 2026

    @627150795
    Contributor

    I opened #264 (#264) for the focused research slice. It defines a failure-class benchmark for logs/tests versus on-demand DAP, including fixed arms, diagnosis rubric, overhead, false leads, adapter failures, cleanup, and side-effect limits. The docs checks passed: git diff --check, bun run lint, and bun run typecheck. It contains no DAP runtime or experimental result.

  4. tt-a1i commented on Sep 8, 2026

    @tt-a1i
    CollaboratorAuthor

    补充 2026-09-08 社区源码调研:找到了可以承接本 Issue 实验的 Pi 原生 DAP 包,不必先运行整个 OMP。OpenPI 本次基线为 ed9dbc1。以下是源码检查,未安装插件、启动调试器或验证修复收益。

    候选为 trotsky1997/pi-lsp-extension 的 lsp-pi 1.0.5,固定 39d56f0。manifest 直接声明 Pi extensions,其中包含 debug.ts;文件开头 明确说明移植 OMP DAP engine,并换成适合 Pi terminal/RPC 的纯文本呈现。它因此是可单独研究的 Pi package,而非把 OMP fork 当插件。

    可学习的是:一次 launch 后跨调用保留调试状态;stack/scopes/variables/output 给出可检查事实;每次请求 合并调用方取消信号和有上限的 timeout,结果包含状态快照。适配器需自行安装。

    当前仍不能直接作为 OpenPI 推荐安装项。 manifest 依赖旧 @mariozechner Pi ^0.66.0,兼容本次运行时尚未验证。一个 debug schema 同时开放 attach、evaluate、变量/内存写入及 custom request;getDapSessionManager 是全局 singleton,并被立即导出,debug.ts 未绑定 Pi Session 生命周期。不能据此假定多个 parent/child Session 有独立调试目标和清理归属。manifest 声明 MIT,但仓库树未发现 LICENSE,复制前还需确认完整许可与归属声明。

    建议把这个候选加入原有 failure-class 实验:先固定兼容版本,仅 launch 自有 fixture,开放 stack/scopes/variables/output/continue/terminate;attach、evaluate、内存写入和 raw request 后置。先证明取消、Session 关闭和异常退出后的目标状态,再比较日志/测试基线。它降低了实验实现成本,尚未证明 debugger 值得进入 OpenPI 默认能力面。

    研究记录:Pi 社区能力研究与候选清单(2026-09-08)。源码证据、运行验证与采用决策分别记录。

  5. tt-a1i commented on Sep 9, 2026

    @tt-a1i
    CollaboratorAuthor

    补充 2026-09-09 源码调研(未 pi install、未启动 adapter、未 attach/launch debuggee、未跑 failure-class)。本地记录:docs/research/EXPERIMENT_DAP_DEBUG_2026-09-09.md(尚未入库)。OpenPI 对照仍是 a9b40f0。

    官方 Pi 没有 DAP。 v0.85.1 / clone 6160683 工具闭集仍是 read|bash|powershell|edit|write|grep|find|ls。隐藏 /debug 只写 pi-debug.log,不是 debugger。LSP(#163)也不是 DAP。

    09-08 只钉了 lsp-pi git。本轮 npm/GitHub 又钉到四个真 Pi-native DAP 包,外加 OMP 内建 28-action 面(Hard-OMP,不能 pi install):

    包 钉住 要点
    @ian-pascoe/pi-dap 0.3.2 / ee30b36 唯一 构造排除 attach、绑 session_start/session_shutdown、12 个 operation 的缝。V1 仍含 evaluate。
    @piex-dev/dap 0.1.1;HEAD 5cd4467 OMP stdio 移植;debug + attach / evaluate / write_memory / custom_request;模块 singleton。
    pi-engineering-services 0.1.1 / a3832c8 piex DAP + pi-lsp + Task;vendor js-debug;常驻 IDE。
    @devinat1/pi-debugger npm 0.1.1;clone 0.2.0 13 个 debug_*;port/PID attach;加载即 editor bridge。
    lsp-pi npm 1.0.5 5590a3b 不含 debug.ts;git 39d56f0 有 35-action debug 09-08 读的是 git。pi install npm:lsp-pi 按已发布 manifest 没有 DAP。

    名叫 debug 但不是 DAP 的:pi-debug-mode(探针工作流)、pi-flutter-run(Dart VM)、pi-browser-debug(Playwright)。不要并进本 Issue。

    当前仍不能推荐安装,也不该先自研 runtime。 第三方扩展会被本 checkout 的 createChildResources 装进 child(只滤 pi-intercom)。attach / evaluate / memory / custom request 是高特权;第一版按正文排除 attach。可学的形状停在 ian-pascoe:预装 adapter、launch-only、单 Session 单树、有界输出。#264 协议仍 CLOSED 未合并。先证明取消/shutdown 后的目标状态和 A vs B,再谈 OpenPI capability。

  6. tt-a1i commented on Sep 9, 2026

    @tt-a1i
    CollaboratorAuthor

    补充 2026-09-09 单包深读(未 pi install、未 npm install、未启动 adapter、未 launch/attach debuggee、未跑包测试)。不重开目录。本地记录:docs/research/EXPERIMENT_PI_DAP_LAUNCH_2026-09-09.md(尚未入库)。OpenPI 对照仍是 a9b40f0。

    钉住 @ian-pascoe/pi-dap 0.3.2:npm tarball shasum 36053a2bf8b782c7cb775e50a3f01ad1f79af8de;git packages/pi-dap ee30b36。src/ / README / LICENSE / skill 与 tarball 字节一致。测试、ADR、vscode-js-debug integration 不进 npm(14 files)。

    文件级(相对 09-09 目录评论多出来的):

    • packages/pi-dap/src/** 零 "attach" 字面量。模型面只有 dap,12-op TypeBox 闭集,additionalProperties: false。dap-tool.test.ts 把 { operation: "attach" } 标成 schema 失败。协议启动只有 request("launch", …)。
    • 生命周期在 pi-dap-extension.ts:加载即 registerTool;session_start 才 new DapSession(仍不 spawn);session_shutdown 先 session.shutdown() 再删 pi-dap-*。每份 ExtensionAPI 一份 controller,不是 globalThis singleton。
    • V1 仍宽于本 Issue 首版:evaluate 发 context: "repl";另有 step/pause/breakpoints。没有独立的 threads/scopes/output op。没有 generation 身份,只有 last-stop threadId + 模型回传的 frame/ref。
    • 反向请求:headless runInTerminal 会 spawn;startDebugging 只放行 一条 js-debug 主目标且 request: "launch"。其它拒绝。Launch Profile arguments 是 opaque JSON——挡住的是 attach 工具/请求,不是受信任 settings 里的任意可执行文件。
    • 清理:disconnect({ terminateDebuggee: true }) + Linux process group;非 Linux 只 child.kill。README 的 V1 写的是 Linux。
    • child: 本 checkout createChildResources 只滤 pi-intercom。CHILD_EXCLUDED_TOOL_NAMES 没有 dap。漂移守卫是双向的——今天把 "dap" 写进排除表会因为本包未注册该名而失败。用户自装则 Direct/Workflow child 会得到工具 和 pi-dap skill(print-mode 不挂 Observer,但不挡 execute)。要堵应做资源过滤,不要破坏守卫。

    仍不推荐安装,也不该整包 Adopt / 先自研 runtime。可学的是 Session 生命周期、launch-only 构造、Trust 门、有界 spill。OpenPI 若将来自有注册:不要用工具名 dap(撞用户自装包);一律 parent-only;evaluate/attach/runInTerminal 首版不注册。#264 协议仍 CLOSED。先臂 A,再谈 capability。

  7. tt-a1i commented on Sep 9, 2026

    @tt-a1i
    CollaboratorAuthor

    补充 2026-09-09 发布身份复验(仍未 pi install、未当 live Pi package 运行、未启动 adapter)。不重开目录,不重述上一则文件级深读。本地记录仍是 docs/research/EXPERIMENT_PI_DAP_LAUNCH_2026-09-09.md。

    钉住 0.3.2 @ 52de485,不是把 HEAD 当成 gitHead。 npm view @ian-pascoe/[email protected] gitHead 为空。SLSA provenance digest.gitCommit、Actions run 34214804650、git tag @ian-pascoe/[email protected] 三者都是 52de485。tarball shasum 仍是 36053a2bf8b782c7cb775e50a3f01ad1f79af8de。monorepo HEAD ee30b36 更新,但 packages/pi-dap 相对 52de485 无 diff。

    #163 ≠ 本 Issue。 lsp_diagnostics 在 OpenPI a9b40f0 / origin/main 0d17f45 / v0.8.1 都是空集(见 EXPERIMENT_LSP_163_ABSENCE_2026-09-09.md)。那是语言服务器诊断,不是 debugger。本包不注册 lsp_*。不要用 Lens 或 @ian-pascoe/pi-dap 替 #163 交差,也不要用「缺 LSP」当「该装 DAP」的理由。本则不评论 #163。

    用户自装仍会漏进 child(双 SHA)。 a9b40f0 只滤 pi-intercom 路径;0d17f45 的 blockedPackageSources 仍只认 intercom。不能把 "dap" 写入双向 CHILD_EXCLUDED。泄漏/过滤留在 #169。仍不推荐安装,也不该整包 Adopt。

    可学件仍是 launch-only 生命周期(Session 身份、构造排除 attach、session_shutdown 清自己的树)。#264 协议仍 CLOSED。先臂 A。

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions