Skip to content

Commit 403170e

Browse files
authored
Merge pull request #6466 from loopx-project/codex/dsh-native-context-20261015
Merge commit for the reviewed head ed3c3b7. What this merge adds: an opt-in DSH native operation transport, restoration of the original approved session across process exit, the matching plugin Loader exports and packed-consumer entries, and a shared Lark card visible-projection repair. Approval, revocation, first consumption and settlement stay with the existing typed operation owner; the new host and connection only pair the provider process with its tool call. Conflict resolution: main and this branch conflicted only in packages/dsh-loopx-plugin/tests/admission-closeout.integration.spec.ts. The merge keeps main's newer unselected-then-selected admission structure and its strict two-receipt assertions, keeps this branch's explicit Todo claim (moved between the unselected and selected calls) and keeps --todo-id on the selected call only. The three-way merge had also spliced --todo-id into main's unselected call, which would have contradicted its selection_required assertion; that is corrected. The spec passes at the merged head. Review findings reconciled: both prior P2 findings are verified repaired at this head and their threads are resolved with evidence replies. The two strict packed consumers now list the four added JS and type entries with the duplicate, chunk and count assertions kept, and the DSH transport has its own DSH_OPERATION_TRANSPORT constant registered with the semantic inventory instead of colliding with the Codex transport name. Validation at this head: exact-head review 5529465206 (APPROVED); premerge canary 5 direct + 19 selected with zero failures; full-tree semantic inventory check and the vocabulary drift smoke pass (conflicting_values 16/16, conflicting_definitions 54/54); plugin validation quality, package and runtime phases pass; plugin typecheck clean and 215 plugin tests pass; admission-to-closeout integration spec passes; 194 backend tests pass with 11 platform skips; change-quality receipt cqr_a2d6e003edff24c75904 recorded as pass. Known holds, not claimed as green: the Release Artifacts goal-workspace-m2 packaged-browser assertion fails identically on unrelated branches, including the dashboard-only adoption branch, so it is a pre-existing main-wide failure rather than a regression of this diff. Unattended wakeup within the 60 second target, source-session return, global installation and financial utility remain unqualified and stay with the original RFC owner. Merge note: this repository's ruleset requires an approval from someone other than the last pusher, while the pull request author is the automation account that GitHub blocks from self-approval. The branch-protection review rule is therefore bypassed by the maintainer under the standing owner authorization for these self-merges; the exact-head review and its readback are published above.
2 parents 21d6649 + 3e8d94a commit 403170e

36 files changed

Lines changed: 2785 additions & 54 deletions

‎docs/architecture/rfcs/human-confirmed-domain-operations-v0.md‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,61 @@ and packaged presentation. The live context probe creates a new managed GPT
453453
session in its owning home; it performs no proposals, group clicks or financial
454454
effects. Synthetic approval fixtures are not genuine user approval.
455455

456+
The optional [DSH native context module](../../../packages/dsh-loopx-plugin/README.md#optional-native-operation-context-sdk-prerequisite)
457+
adds a separately loaded, read-only SDK prerequisite. A real SDK/bundled runtime
458+
`0.1.5rc1` tool call returned its calling session, open native Turn and whitelisted
459+
agent options. This observation is neither a Core actor nor effective wire-profile
460+
attestation; the read-only module always reports `execution_allowed: false`.
461+
462+
The separate optional `native-operation` module and internal
463+
`OwnedDshOperationHost` now connect the real SDK/bundled runtime `0.1.5rc1`
464+
to the existing Core handler. Two separately admitted Turns on one retained
465+
SDK connection qualify native session/Turn/call pairing, observed profile,
466+
canonical preparation, refusal before confirmation, fixture confirmation,
467+
one-shot consumption, rejected repetition and canonical `not_executed` outcome.
468+
File/SQLite Goal authority consumers retain the original action-store owner.
469+
Kernel peer PID and exact SDK-native tool arguments must match the private
470+
bounded Unix connection; there is no bearer, caller actor, second approval store
471+
or effect retry. Legacy Codex executor encoding and default/off behavior remain.
472+
473+
This stage is a backend integration with a scripted loopback provider, not
474+
genuine user approval, original-card delivery or financial utility. SDK
475+
`0.1.5rc1` still refuses cross-process resume before launch; its observed
476+
`session already exists` failure is retained. An isolated Python SDK `0.2.1a3`
477+
wheel built from upstream `2fbf4359`, with explicit npm runtime
478+
`@deepseek-ai/dsh@0.2.1-alpha.3`, uses public `resume_session` instead of
479+
replacing identity. SDK files, Node/entry bytes and the entire npm closure join
480+
the frozen profile. File/SQLite restart cases recover the original operation;
481+
missing/unreadable history refuses without provider input or a reusable failed
482+
client. This is candidate-source qualification, not a published Python runtime
483+
or whole-plugin compatibility claim.
484+
485+
The explicit `turn run-once --host dsh --dsh-operation-module /absolute/native-operation.js`
486+
entry now shares this owner, the existing Todo session planner and the
487+
operator-granted delegation callback. The module flag is default-off and
488+
cannot be combined with `--dsh-runner` or another host. Configuration readback
489+
identifies `owned_native_sdk` but retains `runtime_qualified: false`.
490+
File/SQLite qualification uses the actual CLI, SDK and detached callback to
491+
resume the original persisted session/profile, consume once, reject repetition
492+
and record `not_executed`; the typed wait remains a rejected delegation rather
493+
than validated domain completion. Provider endpoint bytes join the immutable
494+
profile without serializing credentials. The generic `--confirmed-operation-id`
495+
and `--operation-source-route-json` flags retain their Codex aliases.
496+
The CLI fixture does not certify original-card delivery or genuine approval.
497+
498+
A subsequent bounded live qualification used the real model, an actual Lark
499+
card and authenticated human confirmation. Normal native CLI continuation
500+
restored the original DSH session/profile, consumed once, recorded canonical
501+
`not_executed` and patched the same original card; independent provider
502+
readback verified the result. This involved zero financial action. The
503+
continuation was manually invoked after the callback: unattended wakeup was
504+
not configured, and the approximately 246-second confirmation-to-host-start
505+
observation does not meet the 60-second healthy automatic-path target below.
506+
Other runtimes, global installation, account effects and financial utility
507+
remain unqualified. An older globally installed Core rejects the new DSH
508+
executor during inbox projection; the candidate-source entry reads it, so
509+
rollback must retain those pins rather than assume old-reader compatibility.
510+
456511
Public `goal-channel inspect-operation/consume-operation/report-operation`
457512
remain fail-closed before private reads or writes, even with matching
458513
`CODEX_THREAD_ID`, route flags, self-signed proof or an older runtime's actor

‎docs/architecture/rfcs/human-confirmed-domain-operations-v0.zh-CN.md‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,46 @@ context 调用,结果均由既有 typed result validator 接受)、规范
354354
真实 context 探针只在当前拥有的 home 创建新的受管 GPT session,不建提案、
355355
不造群确认、不执行金融副作用;合成批准夹具不是真实用户批准。
356356

357+
可选的 [DSH 原生上下文模块](../../../packages/dsh-loopx-plugin/README.md#optional-native-operation-context-sdk-prerequisite)
358+
交付独立加载的只读 SDK 前置组件。真实 SDK/内置 runtime `0.1.5rc1` 的工具调用
359+
已返回当前调用 session、开放的原生 Turn 和白名单 agent options;该观察不是 Core
360+
actor,也不证明 HTTP wire 实际配置;该只读模块始终返回 `execution_allowed: false`。
361+
362+
独立可选的 `native-operation` 模块和内部 `OwnedDshOperationHost` 现将真实
363+
SDK/内置 runtime `0.1.5rc1` 接到既有 Core handler。同一活 SDK 连接的两个独立
364+
已准入 Turn 覆盖原生 session/Turn/call 配对、实际观察的 profile、规范准备、
365+
确认前拒绝、夹具确认、首次消费、重复拒绝与规范 `not_executed` 结果。
366+
File/SQLite Goal authority 消费者继续使用原 action-store owner。内核 peer PID
367+
及精确原生工具参数必须匹配私有有界 Unix 连接;不新增 bearer、调用者 actor、
368+
批准账本或副作用重试,旧 Codex executor 编码和默认关闭行为保持兼容。
369+
370+
该阶段是使用本地合成响应源的后端集成,不是真实用户批准、原卡送达或金融效用。
371+
SDK `0.1.5rc1` 的跨进程恢复仍在启动前拒绝,原 `session already exists` 失败保留。
372+
隔离候选使用上游 `2fbf4359` 官方脚本构建的 Python SDK `0.2.1a3` wheel,配合
373+
显式 npm runtime `@deepseek-ai/dsh@0.2.1-alpha.3`,通过公开 `resume_session`
374+
恢复原身份。SDK 文件、Node/入口原字节及完整 npm closure 纳入冻结 profile。
375+
File/SQLite 重启用例恢复同一操作;历史丢失/不可读时拒绝,不向模型发送输入,
376+
不替换绑定,失败 client 不可复用。这只是候选源码资格,不能当作已发布 Python
377+
runtime 或整个插件的兼容性证明。
378+
379+
显式 `turn run-once --host dsh --dsh-operation-module /absolute/native-operation.js`
380+
入口现复用该 owner、原 Todo session planner 和 operator 授权的 delegation
381+
callback。模块开关默认关闭,不能与 `--dsh-runner` 或其它 host 混用。配置读回
382+
标明 `owned_native_sdk`,仍保持 `runtime_qualified: false`。File/SQLite 使用
383+
真实 CLI、SDK 和独立 callback 进程恢复原持久 session/profile,首次消费、重复
384+
拒绝并记录 `not_executed`;typed wait 仍是 rejected delegation,不是业务完成。
385+
endpoint 原字节的哈希纳入不可变 profile,不序列化凭据。通用
386+
`--confirmed-operation-id`、`--operation-source-route-json` 保留旧 Codex 别名。
387+
CLI 夹具不证明原卡送达或真实用户批准。
388+
389+
后续有界真实验收使用实际模型、真实 Lark 卡片及经过认证的人类确认。正常原生
390+
CLI 续接恢复原 DSH session/profile,首次消费一次,登记规范 `not_executed`,
391+
并更新同一原卡;独立 provider 读回验证结果,金融动作是零。此续接由角色在
392+
callback 后手动调用:无人值守唤醒尚未配置,实际确认至宿主启动约 246 秒,
393+
不满足下文健康自动路径 60 秒目标。其它 runtime、全局安装、账户副作用和金融
394+
效用仍未验。本机较旧 Core 在 inbox 投影时拒绝新的 DSH executor,候选源码
395+
入口可读;回滚须保留这些 pin,不能假定旧 reader 兼容。
396+
357397
公开 `goal-channel inspect-operation/consume-operation/report-operation` 仍在
358398
私有读写前拒绝,即使 `CODEX_THREAD_ID`、路由、自签 proof 完全匹配或旧运行时
359399
意外返回 actor 成功,也没有 proof-import 捷径。

‎docs/reference/local-delegation.md‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,11 +1258,41 @@ This is a fragment, not a complete collector configuration. `execution_config`
12581258
is project-relative, without traversal or symlinks, and remains outside the
12591259
member workspace. The selected binding must grant that registered requester
12601260
the operation's exact Agent/Todo. Use `codex-cli`, `--codex-operation-tools`
1261-
and the original pinned model/effort. Do not select `fresh`, change the owning
1261+
and the original pinned model/effort, or the explicit DSH entry described below.
1262+
Do not select `fresh`, change the owning
12621263
home, binary, sandbox or effective MCP configuration, or retarget the Todo.
12631264
Prepare the operation in this same managed session/profile. Existing delegation
12641265
inspection and ordinary Turn admission still determine whether it can run.
12651266

1267+
For the candidate DSH transport, prepare through the normal CLI with
1268+
`--host dsh --dsh-operation-module /absolute/native-operation.js` and retain
1269+
those exact options in the original delegation binding. Also pin the original
1270+
`--dsh-runtime-bin`, `--dsh-home`, `--dsh-cordis`, provider/model/effort and token
1271+
budget. The supported restart candidate is Python SDK `0.2.1a3` built from
1272+
official source `2fbf4359` plus explicit npm runtime
1273+
`@deepseek-ai/dsh@0.2.1-alpha.3`; it is not a published Python runtime release.
1274+
SDK/bundled runtime `0.1.5rc1` cannot resume across processes. Do not substitute
1275+
`--dsh-runner`, a replacement home/session, or a changed provider endpoint.
1276+
The native module, SDK/runtime closure, effective profile, patch and endpoint
1277+
hash are compared again before model input. Missing/corrupt history refuses.
1278+
1279+
`--operation-source-route-json '{"host_surface":"registered-surface","thread_id":"registered-thread"}'`
1280+
selects an already registered return audience when required. The original
1281+
source is not executor authentication. `--confirmed-operation-id` is the
1282+
callback-owned exact locator; both flags retain their old Codex aliases.
1283+
Do not supply a locator as proof of confirmation. Removing
1284+
`--dsh-operation-module` disables this transport for subsequent Turns; it does
1285+
not cancel an existing operation or reconcile an uncertain result. Keep the
1286+
old pinned SDK/runtime/profile available for rollback and original recovery.
1287+
Ordinary DSH and legacy Codex paths retain their existing behavior.
1288+
1289+
中文:DSH 候选通过正常 CLI 显式加载绝对路径原生模块,并把相同参数保留在原
1290+
delegation binding。保持原 runtime/home/patch、provider、模型/深度、token
1291+
预算及 endpoint;不能换 session 绕过恢复失败。缺失/损坏历史在模型输入前拒绝。
1292+
配置可用不等于运行资格;夹具确认、派发、规范结果、原卡回传和真实交易分别验收。
1293+
移除模块开关只关闭后续 Turn 的该 transport,不取消旧操作或解除未知结果;保留
1294+
旧 pin 供回滚与原操作恢复,不改全局安装。
1295+
12661296
If the original standalone operation Session was prepared **without** a
12671297
delegation MCP server, its profile includes `mcp_server: null`. Preserve that
12681298
exact profile using the existing operator-owned binding option:

‎examples/personal-workspace-browser/goal-workspace-m2.mjs‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,19 @@ export const goalWorkspaceM2Scenario = {
7676
await now.locator('.work-map').waitFor();
7777
await now.getByRole('button',{name:'按负责人',exact:true}).click();
7878
await now.locator('[data-todo-id="showcase-reconcile"]').click();
79+
await page.waitForURL(value => value.searchParams.get("todo") === "showcase-reconcile");
7980
await page.locator('.personal-drawer-close').click();
81+
await page.waitForURL(value => !value.searchParams.has("todo"));
82+
await page.locator('.personal-context-drawer').waitFor({state:"hidden"});
8083
await page.goBack({waitUntil:"domcontentloaded"});
84+
// Back restores the task just closed, not a selection from an earlier view.
85+
await page.waitForURL(value => value.searchParams.get("todo") === "showcase-reconcile");
8186
await page.locator('.personal-context-drawer').waitFor();
82-
assert.equal(new URL(page.url()).searchParams.get("todo"), "showcase-map-columns");
83-
await page.locator('.personal-drawer-close').click();
87+
await now.locator('[data-todo-id="showcase-reconcile"][aria-pressed="true"]').waitFor();
88+
assert.equal(await now.locator('[data-todo-id="showcase-reconcile"]').getAttribute('aria-pressed'),'true');
89+
await page.goForward({waitUntil:"domcontentloaded"});
90+
await page.waitForURL(value => !value.searchParams.has("todo"));
91+
await page.locator('.personal-context-drawer').waitFor({state:"hidden"});
8492
assert.equal(writes.length,0,`Read-only navigation made an effect request: ${writes}`);
8593
await page.screenshot({path:resolve(outputDir,'goal-workspace-m2-desktop.png'),animations:'disabled'});
8694
await page.setViewportSize({width:390,height:844});

‎loopx/cli_commands/turn.py‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,24 @@ def handle_turn_command(
8989
strict_goal_admission = goal_admission if goal_admission.enabled else None
9090
if getattr(args, "codex_operation_tools", False) and args.host != "codex-cli":
9191
raise ValueError("--codex-operation-tools requires the codex-cli host")
92-
if getattr(args, "codex_confirmed_operation_id", None) and not getattr(
93-
args, "codex_operation_tools", False
92+
dsh_operation_module = getattr(args, "dsh_operation_module", None)
93+
if dsh_operation_module and (
94+
args.host != "dsh" or getattr(args, "dsh_runner", None)
9495
):
96+
raise ValueError("--dsh-operation-module requires the dsh SDK host without --dsh-runner")
97+
if dsh_operation_module and not Path(dsh_operation_module).is_absolute():
98+
raise ValueError("--dsh-operation-module must be an absolute compiled module path")
99+
operation_tools = bool(getattr(args, "codex_operation_tools", False) or dsh_operation_module)
100+
if getattr(args, "codex_confirmed_operation_id", None) and not operation_tools:
95101
raise ValueError(
96102
"confirmed operation continuation requires the owned operation transport"
97103
)
98104
if (
99105
getattr(args, "codex_operation_source_route_json", None) is not None
100-
and not getattr(args, "codex_operation_tools", False)
106+
and not operation_tools
101107
):
102108
raise ValueError(
103-
"--codex-operation-source-route-json requires --codex-operation-tools"
109+
"--operation-source-route-json requires --codex-operation-tools for codex-cli or --dsh-operation-module for dsh"
104110
)
105111
# Planning and dry-run execution inspect existing admitted intents.
106112
# Only an executing wake may sync inboxes or reserve a calendar window.
@@ -164,7 +170,7 @@ def handle_turn_command(
164170
and not getattr(args, "codex_operation_tools", False) else "todo")
165171
if (
166172
args.turn_command == "run-once"
167-
and args.host == "codex-cli"
173+
and (args.host == "codex-cli" or dsh_operation_module)
168174
and not resume_requested
169175
and not args.resume_turn_key
170176
and args.iteration_context != "fresh"
@@ -178,9 +184,10 @@ def handle_turn_command(
178184
turn_envelope,
179185
goal_admission=strict_goal_admission,
180186
session_scope=session_scope,
187+
host=args.host,
181188
)
182189
if strict_goal_admission is not None
183-
else codex_cli_session_binding(runtime_root, turn_envelope, session_scope=session_scope)
190+
else codex_cli_session_binding(runtime_root, turn_envelope, session_scope=session_scope, host=args.host)
184191
)
185192
payload = build_loopx_turn_plan(
186193
turn_envelope,

‎loopx/cli_commands/turn_dsh_host.py‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
from typing import Any
77

88
from ..dsh_goal_mode.turn_host_adapter import DshHostConfig, run_dsh_host
9+
from ..control_plane.goals.first_party_host_admission import FirstPartyHostGoalAdmission
10+
from ..control_plane.turn_driver.execution_profile import managed_execution_profile
11+
from ..control_plane.turn_driver.host_binding import dsh_output_token_budget
12+
from ..dsh_goal_mode.turn_host_adapter import resolve_dsh_home
913
from ..control_plane.operator_credential import (
1014
OPERATOR_CREDENTIAL_ENV_VARS,
1115
OPERATOR_ENDPOINT_ENV_VAR,
@@ -54,3 +58,46 @@ def run(request: Mapping[str, Any]) -> dict[str, Any]:
5458
return run_dsh_host(request, config=config)
5559

5660
return run
61+
62+
63+
def build_dsh_operation_host_runner(
64+
args: argparse.Namespace,
65+
*,
66+
runtime_root: Path,
67+
registry_path: Path,
68+
workspace: Path,
69+
environ: Mapping[str, str],
70+
goal_admission: FirstPartyHostGoalAdmission | None,
71+
) -> DshHostRunner:
72+
"""Bind explicit native transport options; no runner or ambient actor hook."""
73+
from ..control_plane.turn_driver.dsh_operation_host import run_dsh_operation_host
74+
75+
profile = managed_execution_profile(
76+
environ, provider=args.dsh_provider, model=args.dsh_model,
77+
reasoning_effort=args.dsh_reasoning_effort,
78+
)
79+
credential = {
80+
name: str(environ[name])
81+
for name in (*OPERATOR_CREDENTIAL_ENV_VARS, OPERATOR_ENDPOINT_ENV_VAR)
82+
if environ.get(name)
83+
}
84+
options = {
85+
"runtime_root": runtime_root, "registry_path": registry_path,
86+
"project": workspace,
87+
"dsh_home": resolve_dsh_home(workspace, Path(args.dsh_home) if args.dsh_home else None),
88+
"operation_module": Path(args.dsh_operation_module),
89+
"provider": profile["provider"], "model": profile["model"],
90+
"reasoning_effort": profile["reasoning_effort"],
91+
"max_tokens": dsh_output_token_budget(args.dsh_max_tokens)["max_tokens"],
92+
"timeout_seconds": 120 if args.timeout_seconds is None else max(1.0, args.timeout_seconds - 5.0),
93+
"runtime_bin": Path(args.dsh_runtime_bin) if args.dsh_runtime_bin else None,
94+
"cordis": Path(args.dsh_cordis) if args.dsh_cordis else None,
95+
"source_route": args.codex_operation_source_route_json,
96+
"confirmed_operation_id": args.codex_confirmed_operation_id,
97+
"goal_admission": goal_admission, "env": credential,
98+
}
99+
100+
def run(request: Mapping[str, Any]) -> dict[str, Any]:
101+
return run_dsh_operation_host(request, **options)
102+
103+
return run

‎loopx/cli_commands/turn_registration.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,15 @@ def register_turn_commands(
241241
help="Opt in to the owned app-server operation transport for this admitted codex-cli Turn. Reuses the original Todo/session; does not authenticate an attached Desktop or grant domain effects.",
242242
)
243243
run_once.add_argument(
244+
"--confirmed-operation-id",
244245
"--codex-confirmed-operation-id",
246+
dest="codex_confirmed_operation_id",
245247
help="Internal exact-operation resume fence for an operator-granted callback continuation. Requires operation tools; does not authenticate a caller or permit a domain effect.",
246248
)
247249
run_once.add_argument(
250+
"--operation-source-route-json",
248251
"--codex-operation-source-route-json",
252+
dest="codex_operation_source_route_json",
249253
type=json.loads,
250254
help="Registered return audience {host_surface,thread_id} for operation proposals. Required when this Agent has several source routes; not executor authentication or execution permission.",
251255
)
@@ -318,6 +322,10 @@ def register_turn_commands(
318322
help="cordis.yml used by the built-in dsh host runtime.",
319323
)
320324
run_once.add_argument("--dsh-runtime-bin")
325+
run_once.add_argument(
326+
"--dsh-operation-module",
327+
help="Opt in to the owned DSH operation transport with this absolute compiled native-operation module. Requires the real SDK, not --dsh-runner; installation grants no execution permission.",
328+
)
321329
run_once.add_argument(
322330
"--dsh-runner",
323331
help=(

0 commit comments

Comments
 (0)