Skip to content

feat(dsh): promote deepseek-harness adapter to first-class goal-mode subpackage - #3364

Merged
huangruiteng merged 1 commit into
huangruiteng:mainfrom
now-ing:feat/dsh-goal-mode-subpackage
Aug 20, 2026
Merged

feat(dsh): promote deepseek-harness adapter to first-class goal-mode subpackage#3364
huangruiteng merged 1 commit into
huangruiteng:mainfrom
now-ing:feat/dsh-goal-mode-subpackage

Conversation

@now-ing

@now-ing now-ing commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Motivation

deepseek-harness 已经是一等 host surface(start-goal --host-surface deepseek-harness、agent-onboard、host-loop activation packet 都支持),但它的 Turn host adapter 一直是一个 loose 脚本 scripts/dsh_turn_host_adapter.py。其他 host(pi / opencode / opencode2 / kunluncode / claude)都有自己的 loopx/<host>_goal_mode/ 子包。本 PR 把 dsh 升级为同样的一等 loopx/dsh_goal_mode/ 子包,行为与边界完全不变,只改变打包与注册方式。

What changed

  • 新增 loopx/dsh_goal_mode/ 子包(对齐 pi/opencode/kunluncode goal_mode 模式):
    • turn_host_adapter.py:canonical 实现(从 loose 脚本整体迁移,仅把 sys.path hack 换成包内相对导入);
    • __init__.py:re-export 全部公开 API 与 schema 常量;
    • __main__.py:支持 python -m loopx.dsh_goal_mode 直接运行 adapter;
    • README.md:surface、运行方式、requirements、boundary 说明。
  • 向后兼容scripts/dsh_turn_host_adapter.py 保留为 compat launcher,re-export 新子包的全部符号;按文件路径 import(如 examples/dsh-turn-host-adapter-smoke.py)与命令行调用都不变。
  • 注册点指向新模块(保留 legacy 路径字样作为兼容文档):
    • loopx/host_loop_activation.py:agent-type catalog entry_deepseek_harness_activationentry_command_hint / activation steps;
    • loopx/agent_onboarding.py:deepseek-harness start instruction;
    • loopx/bootstrap_command_pack.py:host-surface selection 描述;
    • pyproject.toml:package-data 增加 "loopx.dsh_goal_mode" = ["README.md"]
  • 测试:
    • 新增 tests/test_dsh_goal_mode.py(11 个用例):子包 API、compat shim 与子包符号同一性、签名 authority 提取 fail-closed、prompt 契约、JSON 解析容错、结果整形(fail-closed / 不支持 kind / material 字段补齐)、python -m loopx.dsh_goal_mode 与 legacy launcher 的 hermetic subprocess 全链路(fake dsh runner);
    • 扩展 tests/test_host_loop_activation.py 的 dsh 用例,断言 activation packet 同时引用 loopx.dsh_goal_mode 与 legacy script。
  • 文档:主 README(en/zh-CN)host 表增加 DeepSeek Harness 行与 adapter 链接;docs/integrations/deepseek-harness-connector.mddocs/reference/protocols/loopx-turn-v0.mddocs/integrations/runtime-connector-catalog.md 指向新模块。

Test evidence

venv(python -m venv + pip install -e ".[test]")内运行:

$ python -m pytest tests/test_dsh_goal_mode.py tests/test_host_loop_activation.py \
    tests/control_plane/test_start_goal_compact_projection.py \
    tests/test_gemini_cursor_host_surfaces.py tests/test_agent_onboarding_pi_host.py \
    tests/test_agent_onboarding_unconnected_project.py tests/test_ark_managed_agent_host.py \
    tests/control_plane/test_fine_grained_turn_mode.py tests/control_plane/test_cli_output_budget.py \
    tests/control_plane/test_effect_program_ordered_steps.py -q
186 passed in 21.12s

$ python -m ruff check loopx/dsh_goal_mode scripts/dsh_turn_host_adapter.py \
    tests/test_dsh_goal_mode.py tests/dsh_goal_mode_fake_runner.py \
    loopx/host_loop_activation.py loopx/agent_onboarding.py loopx/bootstrap_command_pack.py
All checks passed!

$ python -m loopx.cli check --scan-path loopx/dsh_goal_mode --scan-path tests/test_dsh_goal_mode.py
... public boundary scan clean: 5 files

$ python examples/dsh-turn-host-adapter-smoke.py    # hermetic adapter smoke
11 checks passed

$ python examples/loopx-turn-dsh-e2e-smoke.py       # fake-dsh Turn e2e
DeepSeek Harness Turn e2e passed

start-goal 冒烟(临时项目,注册 agent 后取 activation packet):

$ python -m loopx.cli --format json start-goal --guided --project <tmp-project> \
    --host-surface deepseek-harness --agent-id dsh-smoke-agent \
    --goal-text "Ship one bounded documentation improvement"
exit: 0
host_surface: deepseek_harness_automation_loop
entry_command_hint: loopx turn run-once with loopx.dsh_goal_mode (python -m loopx.dsh_goal_mode; compat: scripts/dsh_turn_host_adapter.py)
activation_method: external_loop_driver

Notes

  • adapter 的 Turn 契约、fail-closed 语义、session root 隔离等行为均未改动(迁移是 1:1 的,仅移动位置 + 相对导入)。
  • 未跑全量 pytest(按最小相关子集验证);未改 examples/(它们通过 compat launcher 继续工作,已被 smoke 验证)。

…subpackage

Move the DeepSeek Harness Turn host adapter from the loose
scripts/dsh_turn_host_adapter.py launcher into loopx/dsh_goal_mode/,
matching the pi/opencode/kunluncode goal-mode packaging pattern:

- loopx/dsh_goal_mode/turn_host_adapter.py is the canonical implementation;
  run it with python -m loopx.dsh_goal_mode.
- scripts/dsh_turn_host_adapter.py stays as a backward-compatible launcher
  re-exporting the subpackage, so existing commands, examples, and docs keep
  working.
- Point the agent-type catalog, host-loop activation packet, onboarding
  instruction, and bootstrap command-pack description at the new module while
  keeping the legacy path documented.
- Add README and package-data entry, cover the subpackage and the compat
  launcher with tests (hermetic fake dsh runner), and update README/docs.

Signed-off-by: now-ing <24534365+now-ing@users.noreply.github.com>

@huangruiteng huangruiteng left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

详细中文评审(exact head dc784371a0531dbd4ff1b822c9aa7659deb9cf52

动机

这个 PR 解决的是一个真实的交付断层:DeepSeek Harness 已经进入 agent type、start-goal、onboarding 与 host-loop activation 契约,但执行适配器仍只存在于 scripts/dsh_turn_host_adapter.py。脚本路径适合源码 checkout,却不是稳定的 wheel 内模块入口。把 canonical 实现放进 loopx.dsh_goal_mode,同时保留旧脚本兼容入口,使“已注册的一等 host surface”和“可安装、可导入、可用 python -m 启动的实现”终于一致。

改动思路

实现采用了低风险的搬迁方案,而不是重写 Turn 语义:

  1. loopx/dsh_goal_mode/turn_host_adapter.py 承接原脚本实现,只把仓库根目录的 sys.path 注入改成包内相对导入;__main__.py 提供 python -m loopx.dsh_goal_mode__init__.py 暴露现有 adapter API 与 schema 常量。
  2. scripts/dsh_turn_host_adapter.py 缩成兼容 launcher,并把公开符号重新导向同一实现,因此旧的文件路径调用与 import 仍可工作。
  3. host_loop_activation.pyagent_onboarding.pybootstrap_command_pack.py 把新模块标成 canonical 入口,同时保留 legacy launcher 提示;pyproject.toml 把子包 README 纳入 wheel。
  4. 两份主 README、DeepSeek Harness connector、runtime connector catalog 与 Turn v0 协议统一到新入口;测试补齐 package/import/CLI/compat 这条新边界。

具体改动

  • Authority 与 prompt 路径保持不变:extract_turn_authority 仍核对 matchessource_hashenvelope_hash 与重新计算的签名文档,只把签名覆盖的 primary_actionrequired_readswrite_scopeworkspace_guard 交给 dsh;render_prompt 要求唯一、公开安全的 typed JSON 结果。
  • Result 路径保持 fail-closed:parse_model_json 支持纯 JSON、代码围栏和外层文字;build_result 只接受受控的 result kind,缺失或未知 kind 都降为 wait,material kind 才补齐 delivery_batch_scale=single_surfacedelivery_outcome=outcome_progress 与必要的 bounded 字段。
  • Host 执行路径保持不变:main 校验 stdin schema 和签名,隔离本地 session root,构造稳定 session id,经 run_dsh_turn 或显式 runner 执行,再只向 stdout 写一个 loopx_turn_result_v0。请求/签名错误返回 2,SDK/runner 错误返回 1;无法解析最终 JSON 时返回非 material 的 wait
  • 正向链路是:start-goal/activation packet → quota should-runturn run-oncepython -m loopx.dsh_goal_mode → dsh SDK → typed result → LoopX 独立验证和结算。负向链路在 adapter 边界就关闭:被篡改的 envelope 不会进入 host,异常或无效结果也不会伪造进展或获得 quota spend。
  • 17 个变更文件的职责是完整且聚合的:4 个新子包文件承载实现与说明,legacy script 保持兼容,3 个 host 注册/引导文件切换 canonical 入口,pyproject.toml 固化 wheel 数据,5 个公开文档入口同步用户路径,3 个测试/runner 文件验证相同对象身份、模块与旧脚本的 subprocess 契约及 activation packet。

对主干的风险

主要风险是 packaging/compat,而不是业务语义。独立验证结果:

  • focused pytest:184 passed;另有 2 个与本 PR 变更面无关的环境型用例无法在本次 exact-head archive 评审中复现(一个要求测试环境允许临时 git commit,另一个要求 checkout revision metadata),未将它们归因于本 PR。
  • examples/dsh-turn-host-adapter-smoke.py:11 checks passed。
  • examples/loopx-turn-dsh-e2e-smoke.py:通过,含一次写回/一次 quota spend,以及 replay 不重复 host/write/spend 的断言。
  • changed Python surfaces 的 Ruff 检查通过;公开边界扫描 clean。
  • wheel 构建通过,并确认包含 loopx/dsh_goal_mode/{README.md,__init__.py,__main__.py,turn_host_adapter.py}
  • GitHub 在评审时没有返回该 exact head 的 status-check rollup;本结论基于上述独立验证,不代表未上报的外部检查。

残余风险主要是未在本次评审中启动真实 DeepSeek Harness/真实凭据路径;但 PR 没有改变原有 SDK 调用或 provider/model 配置,只改变代码归属和入口,并由 fake-runner 与端到端 Turn smoke 覆盖新 packaging seam,所以这个风险可接受。

我的整体评价

APPROVE。 这是一个主题单一、可回滚且有兼容层的一等化搬迁:新模块入口解决 wheel/源码路径不一致,旧调用不被切断,typed state、domain-neutral Turn 契约、默认行为、guidance/obligation 边界都没有静默变化。测试覆盖了本 PR 真正新增的 package/launcher/activation seam,文档也与运行入口同步;没有发现需要阻塞合并的正确性、权限或公开边界问题。

English verdict: APPROVE at exact head dc784371a0531dbd4ff1b822c9aa7659deb9cf52. The PR moves the unchanged fail-closed DeepSeek Harness Turn adapter into an installable loopx.dsh_goal_mode package, preserves the legacy launcher, updates activation/docs, and validates both entry paths. Focused validation produced 184 passing tests, both hermetic dsh smokes passed, Ruff and the public-boundary scan were clean, and the built wheel contains the new package; no blocking finding remains.

@huangruiteng
huangruiteng merged commit 1248620 into huangruiteng:main Aug 20, 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.

2 participants