Skip to content

工程与发布契约:消除跨扩展内部依赖、测试发现盲区和版本声明漂移 #73

Open

Description

@tt-a1i

问题

当前 main 的功能测试是绿色的,但仍有几处“现在能工作、后续容易静默漂移”的工程合同缺口。

已确认项

1. 跨扩展直接 import 内部实现

当前仍存在:

  • git-read 直接 import file-search/src/output.ts 与 process.ts;
  • workflows 直接 import subagents/src/agent-types.ts。

这些不是公开 shared seam。任一 extension 内部重构都可能破坏另一个 extension,打包边界也变得不清楚。

2. 测试命令只发现一层目录

package.json 当前使用:

node --test --experimental-strip-types extensions/*/*.test.ts

放在 extensions/<name>/src/*.test.ts 的测试不会自动执行,也不会报错。仓库已经有较多 src 子目录,这属于“看起来有测试、CI 实际没跑”的风险。

3. peerDependencies 与公开最低版本不一致

README 宣称 Pi 0.84.1+,开发依赖固定在 ^0.84.1,但发布包对三项 Pi peer 以及 typebox 全部声明 *。npm 无法表达或检查真实兼容下界。

不能机械改成 ^0.84.1,因为 0.x caret 可能错误排除后续 Pi 版本;应先确定兼容范围语义。

4. Worktree 回收失败被静默吞掉

Subagent spawn 失败后会尝试回收刚创建的 worktree,但 reclaimWorktree(...).catch(() => {}) 丢失回收失败证据。此时磁盘可能残留 worktree,用户只看到原始 spawn 错误。

5. 生产代码仍有一个 as any[]

extensions/sessions/index.ts 的 session preview 投影仍使用 context.messages as any[]。不阻塞发布,但它是当前生产代码里残留的明确类型逃逸。

建议

  • 将复用实现提升到 extensions/shared/,或定义小的公开模块接口;
  • 改为递归、确定性的测试发现,并加一个“嵌套 fixture 确实被发现”的守卫;
  • 记录并测试真实 peer 最低版本,选择 >=0.84.1 或经过验证的上界,不机械使用 0.x caret;
  • worktree 清理失败至少进入 tool error details / warning / recovery receipt;
  • 消除最后一个生产 as any。

验收标准

  • extension 不再 import 其他 extension 的 src/ 内部文件;
  • 任意 extensions/**/*.test.ts 都会进入本地与 CI;
  • npm manifest 与 README 的 Pi 兼容声明一致;
  • cleanup 失败可观察、可定位、不会覆盖原始失败;
  • 生产 TypeScript 无 as any。

不包含

Activity

  1. added
    enhancement
    on Aug 22, 2026
  2. 627150795 commented on Aug 28, 2026

    @627150795
    Contributor

    I am taking a narrowly scoped part of this issue: make Subagent worktree cleanup failures visible when spawn aborts, while preserving the original spawn error and the checkout/branch recovery location. I will not duplicate the already-landed recursive test discovery work or claim the unrelated import/peer-version items.

  3. 627150795 commented on Aug 28, 2026

    @627150795
    Contributor

    Update: the cleanup-observability slice is available in PR #258: https://github.com/tt-a1i/openpi/pull/258\n\nIt preserves the original spawn error and now exposes cleanup warnings/failures plus the checkout or branch recovery location. Focused helper tests were added. git diff --check, lint, and typecheck passed. The full worktree suite had one unrelated Windows core.autocrlf line-ending failure (23/24 passed), which is recorded in the PR; this does not change the scope of the fix.

  4. 627150795 commented on Aug 28, 2026

    @627150795
    Contributor

    Validation correction for PR #258: with a per-process core.autocrlf=false setting, the complete worktree suite passes 24/24. The default Windows setting produces the one unrelated LF-vs-CRLF assertion mismatch already recorded in the PR.

  5. 627150795 commented on Aug 29, 2026

    @627150795
    Contributor

    补充代码审计结果:PR #258 在“spawn 中止后的 worktree 清理”范围内有效,能保留原始错误并给出 checkout/branch 恢复位置。worktree 针对性测试在 core.autocrlf=false 下 24/24 通过;默认 Windows 的唯一失败是既有 CRLF 断言差异。正常会话结束清理路径不在该 PR 声明范围内,未将其误报为已覆盖。

  6. 627150795 commented on Aug 29, 2026

    @627150795
    Contributor

    复核后补齐一个真实漏报:spawn 中止时,若 checkout 已删但子代理分支因已有提交而保留、且清理没有附带 reason,之前不会提示恢复分支;现在会明确显示 branch ... remains。修复在 PR #258 最新提交 a4445cd,远端 Node 22/24 与 Windows CI 全部通过。

  7. 627150795 commented on Aug 29, 2026

    @627150795
    Contributor

    代码审计补丁已追加到本 PR:

    • 发现 removed: false 同时覆盖“checkout 脏而保留”和“无法确认 checkout 状态”,旧提示会把未知状态误称为 checkout preserved。
    • 现在改为 checkout was not confirmed removed; inspect ...,不会给出错误的存在性结论;已有提交分支仍明确报告 branch ... remains。
    • 远程提交:fec084b。
    • 验证:worktree 定向测试 26/26 通过;远程 PR 文件差异已核对为原来的 3 个文件,Node 22、Node 24、Windows CI 正在运行。
  8. 627150795 commented on Aug 29, 2026

    @627150795
    Contributor

    我来认领 #73 中尚未完成的“跨扩展内部 import”切片,范围只限 git-read 仍直接依赖 file-search/src/output.ts 与 file-search/src/process.ts 的问题。

    计划:

    • 先增加一个确定性的边界守卫,证明任何 extension 直接 import 另一个 extension 的 src/ 会失败;
    • 将两边真正共享的最小 process/output seam 下沉到 extensions/shared/,不复制实现;
    • 保持命令执行、输出截断、错误语义和模型可见行为不变;
    • 运行相关测试、bun run check 与完整测试。

    本次不处理 peerDependencies 版本范围(需要兼容策略决策),也不重复已经落地的测试发现、worktree 清理和 as any 项。完成并验证后再提交中文 PR。

  9. tt-a1i commented on Sep 9, 2026

    @tt-a1i
    CollaboratorAuthor

    2026-09-09 peer / version pin (source-read + live pi list, no install)

    #73 body still describes README 0.84.1+ / dev ^0.84.1 / Pi+typebox peer *. That sentence is still true on this checkout. It is stale for origin/main and for npm @tt-a1i/[email protected]. This comment does not rewrite the historical issue text, does not change peer ranges, and does not claim the other four #73 slices are done on every tree.

    Pins (2026-09-09):

    Object SHA / version
    OpenPI checkout (this worktree) a9b40f0044ee59c360a6077c1c0bdbdbd30da10b — package 0.4.0, peer three Pi packages + typebox *, bun.lock / node_modules 0.84.1, README 0.84.1+, SETUP.md has no Pi floor, extensions/setup/package-contract.test.ts asserts *
    origin/main 0d17f4577fe31315fe6c95370d251bdb4e2413cf — package 0.8.1, Pi peer >=0.85.1, typebox still *, bun.lock 0.85.1, README/SETUP 0.85.1+
    npm @tt-a1i/openpi latest 0.8.1 @ 2026-09-08T05:00:55Z; registry gitHead none; peer matches origin. Historical: 0.4.0 / 0.5.0 still *; 0.6.0+ already >=0.85.1
    git tag v0.8.1 a3edee28fec813582db6b3b1341754cef4597f81
    Peer-floor commit 20fbcff33aac8f4de29fa1e184d7dbd4e4177d53 (PR #410, closes #395; not an ancestor of a9b40f0). Floor jumped to 0.85.1 because Pi 0.85.0 broke SDK consumers; this is not a locked-vs-latest matrix and not #181 Phase 0.
    Official latest Pi @earendil-works/[email protected] gitHead d981de1229ef899957bbe968bc8dcda02a21f477
    Host CLI on this machine pi --version 0.85.1 (~/.bun/bin/pi and ~/.local/bin/pi are the same symlink)
    pi list OpenPI source on this machine not this checkout and not npm 0.8.1. Settings packages is npm:pi-web-access + ../../work/openpi-main-runtime → /Users/tushaokun/work/openpi-main-runtime @ ed9dbc1018f890fd54375f5371990ddfee8af5df, package 0.7.0, peer >=0.85.1, lock 0.85.1. ~/.pi/agent/npm/node_modules/@tt-a1i is empty. ed9dbc1..0d17f45 is 5 commits.

    So operators can silently edit 0.4.0 / lock 0.84.1 / peer * while the host is Pi 0.85.1 and the loaded OpenPI is a third tree (local path, version label 0.7.0, already on the 0.85.1 peer floor). Version numbers, Issue state, and README badges are not identity. Fail-closed evidence for “which Pi / which OpenPI” is the README provenance chain: checkout HEAD + package.json + lock, pi --version, pi list and that path’s HEAD+version. Missing one layer stays “unverified”.

    #73 item 3 leftover (still this ticket):

    • Issue body last-verified is still the 2026-08-22 * sentence.
    • typebox peer is still * on checkout, origin, runtime, and every published 0.4.0–0.8.1.
    • >=0.85.1 has no upper bound; 0.86+ will not be rejected by the range.
    • Peer is a publish contract, not a loader. Origin .npmrc legacy-peer-deps=true exists so git installs omit-dev; pi list / settings decide which OpenPI source runs.
    • Do not cherry-pick the peer string onto a9b40f0 without the rest of chore(deps): require Pi 0.85.1 and remove server shim #410 (lock, README, SETUP, moved package-contract, .npmrc). This tree’s contract test still requires *.

    Other #73 slices — do not close the issue from peer progress:

    #181 refresh (already commented; not re-opened here): issuecomment-5594654560. Official Pi 0.85.1 is still dual-path (createAgentSession CLI/SDK; AgentHarness experimental). OpenPI on a9b40f0 and 0d17f45 is still AgentSession only. Peer/version leftover stays on #73.

    Record: docs/research/EXPERIMENT_PI_PEER_73_2026-09-09.md (local research index; not committed by this pass). No new Issues. No peer/lock/README edit. No AgentHarness implementation. No pi install.

  10. ooiuuii commented on Sep 11, 2026

    @ooiuuii
    Contributor

    I would like to contribute the remaining peer-compatibility slice of this issue. I checked current main@5bf2fe29e52801d79826c2eb573be403f53285e5 (OpenPI 0.8.1): the three Pi peers are >=0.85.1, TypeBox remains *, and the package-contract test explicitly preserves those ranges. The packed Web CI smoke installs the locked Pi/TypeBox versions; it does not establish compatibility with every future version allowed by the peer ranges.

    Before changing a published compatibility promise, which direction would you prefer?

    1. Keep the existing peer ranges for now; add separately reported supported-baseline/latest-host installation and smoke evidence. This makes compatibility drift visible without rejecting previously accepted installs. A failed future-version probe would be evidence for a subsequent range decision, not automatic proof that the feature PR is broken.
    2. Constrain the ranges to explicitly supported Pi/TypeBox versions, with matching documentation and tests. This prevents unverified future versions from being silently accepted but also narrows installation compatibility and needs an agreed support/update policy.

    I recommend the evidence-first option unless the project has already adopted a bounded support policy. I will not alter peer/lock/README promises until this direction is confirmed. This would not duplicate #368 or the floor already shipped in #410, and would not close the whole of #73.

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