Skip to content

在 omp 19.4.0 上按本地会话收窄 registry 会话再比较 sessionManager - #271

Merged
RiriAgent merged 1 commit into
mainfrom
issue-267
Dec 1, 2026
Merged

RiriAgent merged 1 commit into
mainfrom
issue-267

Conversation

@RiriAgent

Copy link
Copy Markdown
Member

Closes #267

摘要

在 omp 19.4.0 宿主上,index.ts 与 src/ports/host.ts 先用宿主导出的 isLocalAgentSession 把 registry 会话收窄为本地 AgentSession,再比较 sessionManager 的同一性。bun run check 不再报 issue 现场的 6 个类型错误,运行时识别 Main 与 seat 的结果不变。

实现说明

  • 机制:19.4.0 给 AgentSessionManagerHandle 加了 getForkBaseline(),它与 ExtensionContext.sessionManager 的 ReadonlySessionManager 不再有类型重叠。收窄之后,比较的左侧是本地 AgentSession 的 SessionManager,它可以赋给 ReadonlySessionManager,所以 TS2367 消失。host.ts 第 71 行的提前返回不再把 ctx.sessionManager 收窄成 never,后续的 TS2339 随之消失。
    • index.ts DispatchRuntime.start:新增 !isLocalAgentSession(root) || 条件,并新增对 @oh-my-pi/pi-coding-agent/session/agent-session-handle 的 import。
    • src/ports/host.ts createHostPort → bind:新增 !isLocalAgentSession(ref.session) || 条件。这个 import 在该文件里已经存在。
  • 不变边界(结果 2):Main 与所有 seat 都是本进程本线程上由 createAgentSession 建出的本地会话。远端线程的 handle 本来就不可能与 ctx.sessionManager 是同一对象,所以新加的收窄不会排除任何以前能匹配的会话。bind 的返回形状、Caller 和错误文本都不变。
  • 契约:只消费宿主导出(isLocalAgentSession),没有 as、@ts- 指令或手写的同形类型。main() 与 omp-config _shared/caller-session.ts 也是这样收窄的。
  • 未验证与风险:bind 在调用方是远端线程会话时的拒绝分支,没有经运行观察。仿真只建本地会话,这一分支在运行时也到达不了。

…p 19.4.0 compatibility

- Added `isLocalAgentSession` guard in `DispatchRuntime.start` before comparing `root.sessionManager`.
- Added `isLocalAgentSession` guard in host port binding before comparing `ref.session.sessionManager`.

Refs #267
@RiriAgent

Copy link
Copy Markdown
Member Author

证据包

由 ghc 生成 · issue #267 · 结果摘要 a930f2cdaa3a · 2/2 条结果齐全 · 未观察的面 无 · 生成于 2026-12-01T14:50:17.921Z
检出 1def139 patch 06e9d80a3f16618cd429be609dacad4e65dfd8fc

结果 类型 面 步骤 状态 命令 记录
1 改 library run 已记录 sh -c 'echo "host pi-coding-agent $(jq -r .version node_modules/@oh-my-pi/pi-coding-agent/package.json)"; bun run check' exit 0 · 0.5s
2 保持 library run 已记录 sh -c 'echo "$(omp --version) HEAD=$(git rev-parse --short HEAD)"; echo '\''HOME config:'\''; cat /tmp/omp1940/work/plugin-omp-dispatch/home-depth2/.omp/agent/config.yml; HOME=/tmp/omp1940/work/plugin-omp-dispatch/home-depth2 bun tests/sim/run.ts' exit 0 · 149.7s

结果 1 · 改功能 · library

宿主包升到 19.4.0 后,现场里 bun run check 报出的 index.ts(98,79) 与 src/ports/host.ts(71,25)/(79,37)/(80,39)/(84,31)/(92,36) 这 6 个错误不再出现,类型检查以 0 退出。

  • run(1def139,记录 20261201T144724Z-b1e9e4)看点:首行宿主 pi-coding-agent 19.4.0;biome 'No fixes applied',tsc 无输出(没有 TS2367/TS2339),命令退出 0

结果 2 · 保持不变 · library

在 omp 19.4.0 上用 omp --dispatch 启动时,Main 仍被识别为原生 Main 并启动协调者;seat 调用 dispatch_submit / dispatch_verdict / dispatch_escalate 时仍被绑定为本 ticket 的 seat,交接被接受;一次 delivery 照常走到完成。

  • run(1def139,记录 20261201T144726Z-fc4a8d)看点:首行 omp/19.4.0 与 HEAD;真实 omp --dispatch 仿真全部用例 PASS、没有 FAIL 行:每个用例都要求 Main 启动协调者、seat 经 dispatch_submit/dispatch_verdict/dispatch_escalate 交接被接受、agenda 走到 completed(tests/sim/run.ts commonChecks 在 'agenda is … not completed' 时报 FAIL)
结果 1 run · exit 0 · sh -c 'echo "host pi-coding-agent $(jq -r .version node_modules/@oh-my-pi/pi-coding-agent/package.json)"; bun run check'

cwd /private/tmp/omp1940/work/plugin-omp-dispatch/omp-dispatch · /bin/sh · 2026-12-01T14:47:24.024Z – 2026-12-01T14:47:24.534Z · 工作区干净 · 记录 20261201T144724Z-b1e9e4

stdout(共 1 行):

host pi-coding-agent 19.4.0

stderr(共 2 行):

$ biome check . && tsc --noEmit
Checked 83 files in 66ms. No fixes applied.
结果 2 run · exit 0 · sh -c 'echo "$(omp --version) HEAD=$(git rev-parse --short HEAD)"; echo '\''HOME config:'\''; cat /tmp/omp1940/work/plugin-omp-dispatch/home-depth2/.omp/agent/config.yml; HOME=/tmp/omp1940/work/plugin-omp-dispatch/home-depth2 bun tests/sim/run.ts'

cwd /private/tmp/omp1940/work/plugin-omp-dispatch/omp-dispatch · /bin/sh · 2026-12-01T14:47:26.307Z – 2026-12-01T14:49:55.996Z · 工作区干净 · 记录 20261201T144726Z-fc4a8d

stdout(末尾 40 行,共 84 行):

  mcp-scope: +4231ms Main request answered with dispatch_ticket presents mcp__fx_added false
  mcp-scope: +4490ms Main request answered with text presents mcp__fx_added false
  mcp-scope: A owner mcp__fx_added result [{"type":"text","text":"fx added ran"}] isError false
  mcp-scope: seat A owner first request presents mcp__fx_load true; contract tools list dispatch_submit 1 times
  mcp-scope: seat B owner first request presents mcp__fx_load true; contract tools list dispatch_submit 1 times
  mcp-scope: seat A review first request presents mcp__fx_load true; contract tools list dispatch_verdict 1 times
  mcp-scope: seat A accept first request presents mcp__fx_load true; contract tools list dispatch_verdict 1 times
  mcp-scope: seat B review first request presents mcp__fx_load true; contract tools list dispatch_verdict 1 times
  mcp-scope: seat B accept first request presents mcp__fx_load true; contract tools list dispatch_verdict 1 times
  mcp-scope: seat A postMerge first request presents mcp__fx_load true; contract tools list dispatch_verdict 1 times
  mcp-scope: seat B postMerge first request presents mcp__fx_load true; contract tools list dispatch_verdict 1 times
PASS mcp-scope (5.5s) /tmp/dispatch-sim-mcp-scope-W4ng9K
PASS tree-meerkat (37.1s) /tmp/dispatch-sim-tree-meerkat-jojxyC
PASS launch-role (3.4s) /tmp/dispatch-sim-launch-role-LXRUhs
PASS ask (1.2s) /tmp/dispatch-sim-ask-XlxZD5
PASS ask-restart (1.9s) /tmp/dispatch-sim-ask-restart-YmGtmi
  ask-unreachable failure text: POST http://127.0.0.1:61715/v1/asks: ECONNREFUSED: Unable to connect. Is the computer able to access the url?
PASS ask-unreachable (1.2s) /tmp/dispatch-sim-ask-unreachable-9QDQU6
  ask-reply: ticket Done at revision 10, notes ["ask 4000000002 was answered in comment 4000000003"]
  ask-reply: Owner sessions 01a23215-2d5c-7668-9669-c11ca6df14b1 (parentSession null), 01a23215-30bc-72ac-b5a8-e50b9e9bb731 (parentSession 01a23215-2d5c-7668-9669-c11ca6df14b1)
  ask-reply: issue markers impl#4000000001, ask#4000000002, reply#4000000003, impl#4000000004; impl sessions 01a23215-2d5c-7668-9669-c11ca6df14b1, 01a23215-30bc-72ac-b5a8-e50b9e9bb731
  ask-reply: resumed Owner's first user message: "你的询问已得到答复,答复如下。按答复继续实现本 issue。\n\nInclude the tenant id: caches are shared across tenants in one process.\n\nContinue ticket A at revision 3. Only the incremental handoff follows. Use read dispatch://seat"
  ask-reply: Main woken for ["6:finish","6:finish"]
PASS ask-reply (3.4s) /tmp/dispatch-sim-ask-reply-ZPrWZk
  ask-replace: ticket Replaced, terminal {"kind":"replaced","by":"sim/arena#9","comment":4000000003,"at":1796136582699}; Owner sessions 01a23215-3ace-7331-a22e-8e2e3bfa3fe1; PRs 0; agenda completed after Main's finish
PASS ask-replace (1.5s) /tmp/dispatch-sim-ask-replace-2yjZUN
  ask-escalate: two recomputes after the escalation: ticket Asking at revision 2, ask comment 4000000002, council agenda sim/agenda#5, one Owner session, notes ["ask 4000000002 was escalated to the council agenda sim/agenda#5 in comment 4000000003"]
  ask-escalate: ticket Done at revision 10, notes ["ask 4000000002 was escalated to the council agenda sim/agenda#5 in comment 4000000003","ask 4000000002 was answered in comment 4000000004"]
  ask-escalate: Owner sessions 01a23215-4114-7676-a9df-6bdb10ce329e (parentSession null), 01a23215-504b-7621-ad2d-38985b48e879 (parentSession 01a23215-4114-7676-a9df-6bdb10ce329e)
  ask-escalate: issue markers impl#4000000001, ask#4000000002, escalated#4000000003, reply#4000000004, impl#4000000005; impl sessions 01a23215-4114-7676-a9df-6bdb10ce329e, 01a23215-504b-7621-ad2d-38985b48e879
  ask-escalate: resumed Owner's first user message: "你的询问已得到答复,答复如下。按答复继续实现本 issue。\n\nInclude the tenant id: caches are shared across tenants in one process.\n\nContinue ticket A at revision 3. Only the incremental handoff follows. Use read dispatch://seat"
  ask-escalate: Main woken for ["6:finish","6:finish"]
PASS ask-escalate (6.5s) /tmp/dispatch-sim-ask-escalate-2FHZDN
  ask-reply-ignored: two recomputes after the unrelated reply: ticket Asking at revision 2, ask comment 4000000002, council agenda null, one Owner session, notes ["ignored settlement 4000000003 for ask 4000001002"]
  ask-reply-ignored: ticket Done at revision 10, notes ["ignored settlement 4000000003 for ask 4000001002","ask 4000000002 was answered in comment 4000000004"]
  ask-reply-ignored: Owner sessions 01a23215-5ab1-7457-8249-64d4894e395b (parentSession null), 01a23215-69e2-74e6-9599-a95e57a47cd0 (parentSession 01a23215-5ab1-7457-8249-64d4894e395b)
  ask-reply-ignored: issue markers impl#4000000001, ask#4000000002, reply#4000000003, reply#4000000004, impl#4000000005; impl sessions 01a23215-5ab1-7457-8249-64d4894e395b, 01a23215-69e2-74e6-9599-a95e57a47cd0
  ask-reply-ignored: resumed Owner's first user message: "你的询问已得到答复,答复如下。按答复继续实现本 issue。\n\nInclude the tenant id: caches are shared across tenants in one process.\n\nContinue ticket A at revision 3. Only the incremental handoff follows. Use read dispatch://seat"
  ask-reply-ignored: Main woken for ["6:finish","6:finish"]
PASS ask-reply-ignored (6.5s) /tmp/dispatch-sim-ask-reply-ignored-eBINoy

@RiriAgent

Copy link
Copy Markdown
Member Author

Gate 结论 · review · PASS · patch 06e9d80a3f16618cd429be609dacad4e65dfd8fc · HEAD 1def139 · base main · issue rev 2026-12-01T14:17:57Z · 设计 无

结论:PASS

  • 机制与边界(问题 1):index.ts:99-105 与 src/ports/host.ts:69-72 先用宿主导出的 isLocalAgentSession 收窄,再比较 sessionManager。19.4.0 的 AgentSessionManagerHandle 含 getForkBaseline(session/agent-session-handle.ts:56-69),ReadonlySessionManager 不含它(session/session-manager.ts:923-948),所以原比较没有类型重叠。收窄后左侧是本地 AgentSession 的 SessionManager,可以赋给 ReadonlySessionManager。extension context 的 sessionManager 是本 runner 的同一对象,远端 handle 只是代理,不可能与它是同一对象,所以收窄不排除任何以前能匹配的调用方。bind 的返回形状与 Caller 构造不变(src/ports/host.ts:73-98)。diff 中没有 as、@ts- 或手写的同形类型,也没有越界文件。
  • 测试(问题 2):PR 没有新增测试。仓库没有 test 检查,两条结果都由证据记录证明。仿真经真实 omp --mode rpc … --dispatch 入口运行(tests/sim/run.ts:198-238),agenda 未完成时 commonChecks 判失败(tests/sim/run.ts:478-541)。
  • 冗余(问题 3):新加的 guard 同时承担本地会话判定与类型收窄,不是兼容分支或死代码。
  • 证据包(问题 4):记录 20261201T144724Z-b1e9e4 是在宿主 19.4.0 上运行 bun run check 的结果,exit 0,没有 TS2367/TS2339,证明结果 1。记录 20261201T144726Z-fc4a8d 在 omp/19.4.0、HEAD 1def139 上运行全部仿真用例,全部 PASS、exit 0,证明结果 2。accepted verdict 的解析在 tests/sim/run.ts:400-419,escalate 被接受的断言在 tests/sim/ask.ts:96-98。HOME 中的 task.maxRecursionDepth: 2 已在记录里写明,它只隔离 omp 19.4.0 默认 task.maxRecursionDepth 为 1 时 seat 没有 task,提示与 README 仍要求使用 helper #269 的 seat task 问题,不影响会话身份或交接的判定。
  • 未覆盖(问题 5):远端线程会话的拒绝分支没有经运行观察。PR 已写明这一点,而且远端线程会话不是有效调用方。

下一步:合并。

@RiriAgent
RiriAgent merged commit 0c007bb into main Dec 1, 2026
1 check passed
@RiriAgent
RiriAgent deleted the issue-267 branch December 1, 2026 15:05
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.

omp 19.4.0 宿主上 bun run check 失败:会话管理器同一性比较不再通过类型检查

1 participant