Skip to content

fix(collaboration): distinguish delegation entrypoints and preserve canonical peer tasks - #4871

Merged
huangruiteng merged 3 commits into
mainfrom
codex/delegation-route-projection-20260921
Sep 22, 2026
Merged

huangruiteng merged 3 commits into
mainfrom
codex/delegation-route-projection-20260921

Conversation

@huangruiteng

@huangruiteng huangruiteng commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Peer activation, bound delegation and native child admission could contradict one another in the same planning packet: a blocked peer bundle returned before native admission, the first display row hid other tasks owned by that peer, and a successful runtime probe appeared as execution readiness.

This change scopes peer blockers to their entrypoint, preserves canonical task candidates, and allows independently admitted native work while retaining the peer diagnostic. Bound delegation now separates runtime_readiness from execution readiness and explicitly requires the existing delegation inspect preflight. Runtime visibility grants no new authority; the coordinator's selected Todo remains distinct from worker tasks.

Peer candidate/admission rules move into the existing TypeScript effect boundary; Python keeps normalization and assignment identity hashing. Large peer inventories use the existing signed full-decision detail path in TurnEnvelope instead of dropping tasks or expanding its budget. CLI Markdown now displays scope, state and blockers. The integration contract includes Chinese and English guidance.

Validation:

  • 40 focused Python tests, including live quota → envelope → Turn planning, disabled capability isolation and Markdown readback.
  • 30 TypeScript tests, including 50-task ready/blocked, top-level/nested peer projections and signature drift.
  • Control-plane typecheck, Ruff, two existing orchestration integration smokes and diff checks passed.
  • Source CLI agent-context --phase before_plan readback verified the new fields without launching workers. This source environment's provider availability differs from the installed runtime; this is projection validation, not a DSH/Ark launch qualification.
  • Public boundary scans: zero errors. Two pre-existing unrelated Goal warnings remain.

Product entry points: CLI and managed planning projections change. Existing frontend settings edit the unchanged spawn policy/configuration owner, while Lark consumes its existing interaction user-channel projection; neither directly renders these orchestration fields, so no new UI controls or packaged frontend change is needed. No provider launch, live Goal authority migration or installed-runtime upgrade is included.

Branch sync (conflict resolved)

The branch was 53 commits behind main and CONFLICTING. It is now rebased onto the current origin/main, so the PR is mergeable again; both commits keep their Signed-off-by trailer and the PR-only range contains no merge commit.

Only one file needed a real conflict resolution, loopx/control_plane/effect_runtime_handlers.ts: main added the periodic-report and issue-fix Monitor handler imports while this branch added the projectPeerOrchestration import. Both sides were kept — main's imports, this branch's import, and the existing quota.peer_orchestration.project handler registration are all present. The final diff against origin/main for that file is exactly the intended +5/-0 (one import, one handler entry).

tests/test_turn_machine_credential.py auto-merged: main had added assertions for the verified identity context, and the rebased diff still carries this branch's runtime_readiness=ready / readiness=unknown / preflight=required assertions. No other file in the PR changed on main between the old merge base and the new base, so no other auto-merge reconciliation was possible.

Re-validated on the rebased head: 58 focused Python tests, 30 TypeScript peer/TurnEnvelope/agent-context tests, control-plane tsc --noEmit, Ruff, mypy, git diff --check, and loopx canary premerge (16 checks, 0 failures).

The rebase also surfaced one repair that was missing from the earlier head: examples/codex-subagent-orchestration-contract-smoke.py still asserted the sentence this PR removed from docs/integrations/codex-subagent-orchestration.md. That smoke is part of the full-public suite the repository runs on every push to main, so merging without the repair would have broken main. A third commit now asserts the replacement sentences ("Only currently actionable candidates appear under eligible_peer_lanes", "Closed, blocked, or deferred Todos are excluded", "appears under blocked_peer_lanes"), keeping the same durable invariant pinned to the documentation. All 44 full-public smokes matching this PR's surfaces now pass locally.

@huangruiteng huangruiteng left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Approval conclusion cannot be issued yet (author-owned PR; GitHub blocks formal self-review)

Exact head reviewed: 8e45e40bcaf666b52cbcf57a744b634483a3b6f0

动机

这个 PR 要解决的是真实且高影响的协作语义混淆:peer activation、native child admission、bound delegation 是三个不同入口,但旧实现会让 blocked peer bundle 提前遮住可运行的 native work;同一 peer 的多个 canonical Todo 又会被“每个 peer 只保留第一行”的投影丢失;同时,provider/runtime 可达性会被投影成 execution readiness=ready。这三类问题都会让 coordinator 把“可见/可达”误当成“已获执行授权”,或者直接漏掉应处理的任务。

从目标边界看,本 PR 的切片是合理的:它不声称启动 worker、迁移 Goal authority 或完成 provider qualification,只修复规划与投影层的入口隔离、任务完整性和 readiness 语义。

改动思路

整体架构方向正确:

  • peer 候选与 gate 判定移到既有 TypeScript effect decision boundary;Python 保留输入归一化、IO 和 assignment identity。
  • canonical candidate 以 (claimed_by, todo_id) 去重,避免同一 peer 的不同 Todo 互相覆盖。
  • blocked peer contract 作为 diagnostic 保留,但不再替换独立通过 admission 的 native work lane。
  • delegation 将 runtime_readiness 与 execution readiness 拆开;runtime 可达时仍要求既有 delegation inspect preflight。
  • 大 peer inventory 不抬高 TurnEnvelope 预算,而是保留 count、content hash、detail_refread_required,执行前必须读取 full decision。

正向路径上,一个 live registered peer 拥有两个 open canonical Todo 时,两条 lane 都会保留;capability、runtime、resume gate 必须分别满足。负向路径上,peer stale/activation unavailable 只会形成 blocked diagnostic,不会吞掉 native admission;runtime probe 成功也不会授予 delegation execution authority。

具体改动

关键代码讲解

  1. loopx/control_plane/quota/peer_orchestration.ts::projectPeerOrchestration

    这是新的 peer admission 决策 owner。它只接受 registered、非 self、open advancement Todo;以 peer + Todo 双键去重,并独立检查 peer_agent_activation、runtime liveness、stale state 与 resume readiness。没有 substring/prose classifier,也没有把 binding 当成 authority。

  2. loopx/control_plane/quota/task_orchestration.py::apply_task_orchestration_contract

    这里修复了 precedence:只有 execution_state=ready 的 orchestration contract 才替换 fallback work lane;blocked peer contract 仍返回给调用者作为诊断,但 native fallback 保持可运行。这正面关闭了“一个 blocked peer bundle 隐藏另一个入口”的根因。

  3. loopx/control_plane/collaboration/delegation_context.py::project_delegation_context

    provider/runtime probe 成功后现在输出 runtime_readiness=readyreadiness=unknownpreflight=required,把“机器可达”与“delegated execution 已批准”明确分离。

  4. loopx/control_plane/quota/turn_envelope.ts::compactPeerActivation

    只有 peer contract 超过 context section target 时才压缩;压缩结果保留 scope、state、gate、count、canonical hash 与 full-decision detail_ref,并明确 counts 不是 executable lanes。50-task top-level/nested projection与签名漂移测试通过。

精确 diff 共 14 个文件,+399/-154;其中生产代码总体收敛了 Python 重复选择逻辑,没有引入第二套 durable authority。

对主干的风险

[P1] 共享 delegation readiness 迁移还没有覆盖既有消费者

仓库 CI 的 test-shard (2) 在当前 exact head 上直接失败:

tests/test_turn_machine_credential.py::test_delegation_uses_machine_readiness_without_expanding_requesters

现有断言仍要求:

packet["routes"][0]["readiness"] == "ready"

而本 PR 有意返回 readiness=unknown。这不是无关 flaky:失败测试正好覆盖本 PR 修改的 machine provider → delegation projection 公共路径。新的 focused tests 已验证新实现,但旧的真实消费者合同没有一起迁移,因此当前分支既让 required suite 变红,也没有证明所有既有 caller 已理解 runtime_readiness / readiness / preflight 的拆分。

最小修复不是删掉断言,而是:

  • 把该回归更新为 runtime_readiness=readyreadiness=unknownpreflight=required
  • 保留 coordinator/worker scope 和 credential boundary 的原断言;
  • 搜索并迁移其它把 runtime availability 当 execution readiness 的 sibling consumers;
  • 重跑:
uv run --extra test pytest -q \
  tests/test_turn_machine_credential.py \
  tests/control_plane/test_delegation_context.py \
  tests/control_plane/test_task_orchestration_admission.py

我本地验证了 40 个相关 Python tests、30 个 TypeScript tests、Ruff、diff check 和基于当前 origin/main 的 conflict-free merge tree;这些都通过。远端其它失败中,Node minimum 的 SQLite runtime qualification、credential fixture 干扰和 refresh-state fixture 缺字段不是本 PR 的核心 blocker;上面这一个 readiness 失败则与改动直接同域,必须修。

语义与 CI 对齐

新 contract 命名与 authority 边界本身是对齐的:execution_scope=peer_agent_activation,delegation 又明确要求 preflight,不夸大 actor lifecycle。但当前 exact head 还没有把这个新共享语义迁移到已有 required consumer,所以 semantic alignment 仍是 not_yet_proven,不能批准。

我的整体评价

方向、owner placement、typed state 以及 bounded compaction 都是好的,且这个 PR 比旧实现更不容易制造第二套权威。未来向重构也恰当地把 peer decision 从 Python 收敛到 TypeScript,而不是再加一层泛化框架。

但当前不能 APPROVE:一个直接受影响的既有公共 caller regression 在 exact head 上失败,说明语义迁移尚未闭环。修复上述 P1、确认 remote head 未变并重新跑相关套件后,可以做一次聚焦复审;无需扩大到 provider launch 或其它不相关重构。

English verdict: REQUEST_CHANGES - The architecture correctly separates peer activation, native admission, and delegation readiness, but an existing directly affected delegation consumer still asserts the old readiness=ready contract and fails on this exact head. Migrate it to runtime_readiness=ready, readiness=unknown, and preflight=required, then rerun the affected suites.

@huangruiteng huangruiteng left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

Exact head reviewed: 8e45e40bcaf666b52cbcf57a744b634483a3b6f0

动机

这个 PR 要解决的是真实且高影响的协作语义混淆:peer activation、native child admission、bound delegation 是三个不同入口,但旧实现会让 blocked peer bundle 提前遮住可运行的 native work;同一 peer 的多个 canonical Todo 又会被“每个 peer 只保留第一行”的投影丢失;同时,provider/runtime 可达性会被投影成 execution readiness=ready。这三类问题都会让 coordinator 把“可见/可达”误当成“已获执行授权”,或者直接漏掉应处理的任务。

从目标边界看,本 PR 的切片是合理的:它不声称启动 worker、迁移 Goal authority 或完成 provider qualification,只修复规划与投影层的入口隔离、任务完整性和 readiness 语义。

改动思路

整体架构方向正确:

  • peer 候选与 gate 判定移到既有 TypeScript effect decision boundary;Python 保留输入归一化、IO 和 assignment identity。
  • canonical candidate 以 (claimed_by, todo_id) 去重,避免同一 peer 的不同 Todo 互相覆盖。
  • blocked peer contract 作为 diagnostic 保留,但不再替换独立通过 admission 的 native work lane。
  • delegation 将 runtime_readiness 与 execution readiness 拆开;runtime 可达时仍要求既有 delegation inspect preflight。
  • 大 peer inventory 不抬高 TurnEnvelope 预算,而是保留 count、content hash、detail_refread_required,执行前必须读取 full decision。

正向路径上,一个 live registered peer 拥有两个 open canonical Todo 时,两条 lane 都会保留;capability、runtime、resume gate 必须分别满足。负向路径上,peer stale/activation unavailable 只会形成 blocked diagnostic,不会吞掉 native admission;runtime probe 成功也不会授予 delegation execution authority。

具体改动

关键代码讲解

  1. loopx/control_plane/quota/peer_orchestration.ts::projectPeerOrchestration

    这是新的 peer admission 决策 owner。它只接受 registered、非 self、open advancement Todo;以 peer + Todo 双键去重,并独立检查 peer_agent_activation、runtime liveness、stale state 与 resume readiness。没有 substring/prose classifier,也没有把 binding 当成 authority。

  2. loopx/control_plane/quota/task_orchestration.py::apply_task_orchestration_contract

    这里修复了 precedence:只有 execution_state=ready 的 orchestration contract 才替换 fallback work lane;blocked peer contract 仍返回给调用者作为诊断,但 native fallback 保持可运行。这正面关闭了“一个 blocked peer bundle 隐藏另一个入口”的根因。

  3. loopx/control_plane/collaboration/delegation_context.py::project_delegation_context

    provider/runtime probe 成功后现在输出 runtime_readiness=readyreadiness=unknownpreflight=required,把“机器可达”与“delegated execution 已批准”明确分离。

  4. loopx/control_plane/quota/turn_envelope.ts::compactPeerActivation

    只有 peer contract 超过 context section target 时才压缩;压缩结果保留 scope、state、gate、count、canonical hash 与 full-decision detail_ref,并明确 counts 不是 executable lanes。50-task top-level/nested projection与签名漂移测试通过。

精确 diff 共 14 个文件,+399/-154;其中生产代码总体收敛了 Python 重复选择逻辑,没有引入第二套 durable authority。

对主干的风险

[P1] 共享 delegation readiness 迁移还没有覆盖既有消费者

仓库 CI 的 test-shard (2) 在当前 exact head 上直接失败:

tests/test_turn_machine_credential.py::test_delegation_uses_machine_readiness_without_expanding_requesters

现有断言仍要求:

packet["routes"][0]["readiness"] == "ready"

而本 PR 有意返回 readiness=unknown。这不是无关 flaky:失败测试正好覆盖本 PR 修改的 machine provider → delegation projection 公共路径。新的 focused tests 已验证新实现,但旧的真实消费者合同没有一起迁移,因此当前分支既让 required suite 变红,也没有证明所有既有 caller 已理解 runtime_readiness / readiness / preflight 的拆分。

最小修复不是删掉断言,而是:

  • 把该回归更新为 runtime_readiness=readyreadiness=unknownpreflight=required
  • 保留 coordinator/worker scope 和 credential boundary 的原断言;
  • 搜索并迁移其它把 runtime availability 当 execution readiness 的 sibling consumers;
  • 重跑:
uv run --extra test pytest -q \
  tests/test_turn_machine_credential.py \
  tests/control_plane/test_delegation_context.py \
  tests/control_plane/test_task_orchestration_admission.py

我本地验证了 40 个相关 Python tests、30 个 TypeScript tests、Ruff、diff check 和基于当前 origin/main 的 conflict-free merge tree;这些都通过。远端其它失败中,Node minimum 的 SQLite runtime qualification、credential fixture 干扰和 refresh-state fixture 缺字段不是本 PR 的核心 blocker;上面这一个 readiness 失败则与改动直接同域,必须修。

语义与 CI 对齐

新 contract 命名与 authority 边界本身是对齐的:execution_scope=peer_agent_activation,delegation 又明确要求 preflight,不夸大 actor lifecycle。但当前 exact head 还没有把这个新共享语义迁移到已有 required consumer,所以 semantic alignment 仍是 not_yet_proven,不能批准。

我的整体评价

方向、owner placement、typed state 以及 bounded compaction 都是好的,且这个 PR 比旧实现更不容易制造第二套权威。未来向重构也恰当地把 peer decision 从 Python 收敛到 TypeScript,而不是再加一层泛化框架。

但当前不能 APPROVE:一个直接受影响的既有公共 caller regression 在 exact head 上失败,说明语义迁移尚未闭环。修复上述 P1、确认 remote head 未变并重新跑相关套件后,可以做一次聚焦复审;无需扩大到 provider launch 或其它不相关重构。

English verdict: REQUEST_CHANGES - The architecture correctly separates peer activation, native admission, and delegation readiness, but an existing directly affected delegation consumer still asserts the old readiness=ready contract and fails on this exact head. Migrate it to runtime_readiness=ready, readiness=unknown, and preflight=required, then rerun the affected suites.

@huangruiteng

Copy link
Copy Markdown
Collaborator Author

已修复这个 P1,并完成 sibling consumer 审计。

Exact head: 5feecdaff50c0318738634cf3c61b678dcefbd36

  • 既有 machine credential 回归现在同时断言 runtime_readiness="ready"、execution readiness="unknown" 与 top-level preflight="required";coordinator/worker scope 和 credential boundary 断言保持不变。
  • 审计了 collaboration projection、CLI/Turn 透传、前端/Lark 以及相关 TS/Python fixtures;未发现其它仍把 runtime availability 当作 delegation execution readiness 的消费者。
  • 同步纳入了 main 已存在的 Turn identity env 期望,使指定 focused suite 在当前分支可独立通过。

验证:

uv run --extra test pytest -q tests/test_turn_machine_credential.py tests/control_plane/test_delegation_context.py tests/control_plane/test_task_orchestration_admission.py
34 passed

node --no-warnings --experimental-strip-types --test tests/control_plane_ts/agent_context.test.ts
12 passed

uv run --extra test ruff check tests/test_turn_machine_credential.py
All checks passed

git diff --check
passed

PR 保留给 owner review,未合并。

@huangruiteng huangruiteng left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

Exact head reviewed: 5feecdaff50c0318738634cf3c61b678dcefbd36

动机

这个 PR 修复的是一个真实的协作控制面问题:registered peer activation、native child admission 和 bound delegation 是三个拥有不同准入权威的入口,但旧投影会让 blocked peer bundle 提前遮住可运行的 native lane;同一 peer 的多个 canonical Todo 又会被“按 Agent 去重”的展示逻辑吞掉;provider/runtime 可达还会被误投影成 execution readiness=ready

我重新从原问题而不是上一轮 blocker 出发审查了当前完整 head。结论是这个切片完整且比例合理:它不启动 worker、不迁移 Goal authority、不做 provider qualification,只把任务身份、入口范围与执行权威重新对齐。仅修测试或改提示文案无法修复真实的选择 owner 和 precedence,因此当前跨 TypeScript decision、Python adapter、Turn/CLI consumer 的范围是必要的。

改动思路

架构路径收敛得比较好:

  • canonical Todo authority 提供完整候选,projectPeerOrchestration 在既有 TypeScript effect runtime 中按 (claimed_by, todo_id) 保留每条 lane,并分别判断 capability、runtime/stale 与 resume gate;
  • Python 只做权威源选择、字段归一化和 assignment identity,不再复制 peer admission 决策;
  • 只有 execution_state=ready 的 peer contract 才能提前成为工作 lane;blocked peer contract 会作为 peer_activation_diagnostic 附着到独立通过的 adaptive native contract,不能遮住 native work;
  • delegation 把 runtime_readiness 与 execution readiness 分离,runtime ready 仍输出 readiness=unknownpreflight=required,实际准入继续由现有 loopx delegation inspect 负责;
  • 大 peer inventory 不抬高 TurnEnvelope 总预算,而是保留 scope、gate、lane counts、canonical content hash 与必读 full_decision 引用;counts 本身不能用于选择任务。

正向路径上,同一 running peer 的两条 open canonical Todo 都保留且进入 assignment signature。负向路径上,peer activation 缺 capability、runtime stale/dormant 或 resume 未满足都会产生精确 reason code;若 native admission 同时成立,native lane 仍可执行。默认关闭路径也保持隔离:未启用 multi_subagent 时 source CLI 返回 agent_context=null,不会加载新 guidance 或产生副作用。

具体改动

关键代码讲解

  1. loopx/control_plane/quota/peer_orchestration.ts::projectPeerOrchestration

    新的 peer admission 决策 owner。它只接受 registered、非 self、open advancement Todo,按 peer + Todo 双键去重;activation、liveness/stale 和 resume 是独立门禁。结果使用精确字段和 reason codes,没有 substring/prose classifier,也不会把 binding 或 runtime visibility 当成执行授权。

  2. loopx/control_plane/quota/task_orchestration.py::_task_orchestration_contract

    这里修复入口 precedence:只有 actionable peer contract 才提前返回;blocked peer 继续进入既有 adaptive native admission,并在成功时作为 diagnostic 附着。没有 native lane 时则保留原 fallback work lane,所以“一个入口受阻”不会变成“所有入口受阻”。

  3. loopx/control_plane/collaboration/delegation_context.py::_routeloopx/control_plane/subagent_context.ts::boundedDelegationContext

    这两个生产边界共同完成兼容迁移:新源显式输出 runtime_readinessreadinesspreflight;旧的 readiness=ready 输入在 bounded projection 中也只会被解释为 runtime ready、execution unknown。当前 head 已把上一轮失败的 machine-credential consumer 同步迁移,并保留 requester scope 与 credential boundary 断言。

  4. loopx/control_plane/quota/turn_envelope.ts::compactPeerActivation

    仅当 task_scoped_peer 超过既有 context target 时压缩,且保留权威字段、两类 lane 数量、content hash 和 read_required/detail_ref。50-task、top-level/nested、ready/blocked 与 signature drift 都有回归覆盖;完整 source contract 仍参与 action signature。

  5. loopx/presentation/renderers/quota_markdown.py::render_quota_should_run_markdown

    CLI 现在分别呈现主 orchestration 与 peer_activation_diagnostic 的 scope、state、selection、capability、blocker 和 required detail,避免 operator 再从一个笼统的 lane count 推断执行权威。

整个 diff 是 15 个文件、+412/-156。其中最大的生产改动删除了 Python 中 123 行重复选择逻辑;两笔 commit 都有 DCO sign-off,公开边界扫描未发现本地路径、私有状态或凭据材料。

对主干的风险

没有发现新的 blocking finding。上一轮 P1 已在当前 exact head 修复:既有 machine-credential 回归现在断言 runtime_readiness=readyreadiness=unknownpreflight=required,并继续验证 coordinator/worker requester scope 与 credential 隔离。仓库范围的 sibling scan 没发现仍把 runtime availability 当 execution readiness 的生产 consumer。

我执行的验证:

  • 相关 Python 全路径:44 passed;
  • peer admission、agent-context、TurnEnvelope TypeScript:30 passed;
  • control-plane TypeScript typecheck:passed;
  • Ruff 与 git diff --check:passed;
  • task-orchestration-smoke.pysubagent-status-projection-smoke.py:passed;
  • source CLI agent-context --phase before_plan 的默认关闭读回:ok=trueread_only=trueagent_context=null
  • 当前 origin/main 与该 head 的 merge-tree 未出现 conflict marker。

语义与 CI 对齐

这个 PR 是对现有 vocabulary 的扩展,不是另起一套 actor lifecycle:peer_agent_activation、adaptive multi_subagentbound_delegation 仍由各自 owner 决策;runtime_readiness 只描述 probe,readiness/preflight 描述委派准入。代码、双语文档、provider revision v5、旧 consumer 和 focused suites 在当前 head 上已经对齐。按 Goal 配置本次没有读取或等待远端 CI;本地 required validation 无失败或 skip。

剩余风险是该 PR 当前落后于 main。任何 rebase/update 都会产生新 head,必须重新做 exact-head review 与 merge-readiness;当前 approval 不跨 head 继承。没有做真实 provider worker launch,因为本 PR 的边界是 read/projection/admission semantics,launch qualification 明确不在范围内。

我的整体评价

当前 head 已经闭合上一轮 blocker,而且没有用“改掉失败断言”掩盖问题:它同时迁移了共享 consumer、复核了 sibling consumers,并通过真实 quota/Turn/CLI 路径验证新语义。authority placement、default-off isolation、domain-neutral wording、guidance-vs-obligation 和大列表预算处理都符合现有架构。

未来向重构也做在了正确的边界:peer gate 从 Python 收敛到一个 TypeScript owner,而不是再增加第二套 durable state 或通用框架;在没有新增 caller 需求前,无需继续扩大抽象。我对当前 exact head 的结论是 APPROVE,但这不是 merge authority,分支更新后需要重新审阅。

English verdict: APPROVE - head 5feecda closes the prior readiness-consumer gap, preserves canonical peer tasks, keeps peer/native/delegation authority separate, and passes 44 Python tests, 30 TypeScript tests, typecheck, Ruff, two integration smokes, diff hygiene, and default-off source CLI readback; any rebased head requires a fresh review.

@huangruiteng
huangruiteng force-pushed the codex/delegation-route-projection-20260921 branch from 5feecda to 90b256e Compare September 22, 2026 05:09
… candidates

Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
@huangruiteng
huangruiteng force-pushed the codex/delegation-route-projection-20260921 branch from 90b256e to 19c1ff6 Compare September 22, 2026 05:18
The peer-contract documentation now scopes the contract to
`execution_scope=peer_agent_activation`, states that only currently actionable
candidates appear under `eligible_peer_lanes`, and places a dormant or
dependency-blocked candidate under `blocked_peer_lanes` instead of dropping it.

That intentional rewrite removed the sentence this smoke asserted, so the smoke
failed while the contract itself stayed true. Assert the replacement sentences
so the durable invariant (closed, blocked, and deferred Todos never become
activation candidates, and a dormant peer is surfaced as a blocked lane) is
still pinned to the documentation.

Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>

@huangruiteng huangruiteng left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

Exact head reviewed: e44a44b764a9b0af0031850dbc1d3c64148cfc3c

动机

这个 PR 修复的是一个真实的协作控制面问题:registered peer activation、native child admission 和 bound delegation 是三个拥有不同准入权威的入口,但旧投影会让 blocked peer bundle 提前返回、遮住可运行的 native lane;同一 peer 的多条 canonical Todo 会被“按 Agent 去重”的展示逻辑吞掉;provider/runtime 可达还会被投影成 execution readiness。

本次任务是在分支 CONFLICTING 且落后 main 53 个 commit 的情况下把它修到可合并。rebase 到当前 origin/maine64fdbece)后只有一处真实冲突:loopx/control_plane/effect_runtime_handlers.tsmain 新增了 periodic-report 与 issue-fix Monitor 的 handler import,本分支新增了 projectPeerOrchestration import;解法是两边都保留,最终该文件相对 main 的 diff 恰好是预期的 +5/-0(一行 import、一条 quota.peer_orchestration.project 注册)。tests/test_turn_machine_credential.py 是自动合并:main 新增的 verified identity 断言与本分支新增的 runtime_readiness=ready/readiness=unknown/preflight=required 断言同时存在。本 PR 其余文件在旧 merge base 到新 base 之间没有被 main 改过,因此不存在别的静默合并点。

rebase 还暴露出一处必须在合并前修掉的真实回归:examples/codex-subagent-orchestration-contract-smoke.py 仍然断言本 PR 从 docs/integrations/codex-subagent-orchestration.md 删掉的那句话。该 smoke 属于仓库在每次 push main 时执行的 full-public 套件(full-public-smokes.yml 的 paths 包含 docs/**),所以直接合并会把 main 打红。新增的第三个 commit 改为断言替换后的句子,语义不变。

改动思路

架构路径收敛得比较好:

  • canonical Todo authority 提供完整候选,peer admission 决策移到既有 TypeScript effect boundary(projectPeerOrchestration),按 (claimed_by, todo_id) 保留每条 lane,activation capability、liveness/stale、resume readiness 是三个独立门禁;
  • Python 只做权威源选择、字段归一化与 assignment identity 哈希,不再复制 peer admission 决策(本 PR 净删除 76 行 Python);
  • 只有 actionable peer contract 才提前成为工作 lane;blocked peer contract 会作为 peer_activation_diagnostic 附着到独立通过的 adaptive native contract,不能遮住 native work;
  • delegation 把 runtime_readiness 与 execution readiness 分离,runtime ready 仍输出 readiness=unknownpreflight=required,实际准入继续由既有 loopx delegation inspect 负责;
  • 大 peer inventory 不抬高 TurnEnvelope 总预算,而是保留 scope、gate、lane counts、canonical content hash 与必读 full_decision 引用;counts 本身不能用于选择任务。

正向路径上同一 running peer 的两条 open canonical Todo 都保留并进入 assignment signature;负向路径上 activation 缺 capability、runtime stale/dormant 或 resume 未满足都会产生精确 reason code,而 native admission 仍可执行。默认关闭路径保持隔离:未启用 multi_subagent 时不会加载新 guidance 或产生副作用。

具体改动

16 个文件、+406/-156:生产代码 +173/-133(Python 净减 76 行)、测试 +192、双语文档 +52/-14、smoke 同步 +3/-1

关键代码讲解

  1. loopx/control_plane/quota/peer_orchestration.ts::projectPeerOrchestration(新增,62 行)

    新的 peer admission 决策 owner。只接受 registered、非 self、open、非 done、advancement_task 且带非空 todo_id 的候选,按 (claimed_by, todo_id) 双键去重;activation、liveness/stale 与 resume 是独立门禁。结果使用精确字段与 reason codes,没有 substring/prose classifier,也不会把 binding 或 runtime visibility 当成执行授权。

  2. loopx/control_plane/quota/task_orchestration.py::_task_orchestration_contract

    修复入口 precedence:只有 task_orchestration_contract_is_actionableexecution_state=ready)的 peer contract 才提前返回;否则继续进入既有 adaptive native admission,并在成功时作为 peer_activation_diagnostic 附着;mode != multi_subagentspawn_allowed != truemax_children 非法时返回 peer contract 而不是 None,诊断不丢。

  3. loopx/control_plane/quota/task_orchestration.py::_registered_peer_task_orchestration_contract

    改为「canonical inventory 优先」:agent_todo_source_items 即使显式为空的 list 也优先于展示行,字段收敛到固定集合;决策改为调用 effect_runtime_result("quota.peer_orchestration.project", ...),Python 只保留 peer_work_key 的 assignment identity 哈希。删除了原来的 Python lane 循环与 _peer_runtime_state_by_agent

  4. loopx/control_plane/collaboration/delegation_context.py::_routeloopx/control_plane/subagent_context.ts::boundedDelegationContext

    两个生产边界共同完成兼容迁移:新源显式输出 runtime_readinessreadinesspreflight/execution_scope;bounded projection 把旧的 readiness=ready 输入解释为 runtime ready、execution unknown。上一轮失败的 machine-credential consumer 已同步迁移。guidance revision 由 v4 升到 v5。

  5. loopx/control_plane/quota/turn_envelope.ts::compactPeerActivation

    仅当 task_scoped_peer 超过既有 section target 时压缩,保留权威字段、两类 lane 数量、content hash 与 read_required/detail_refturnActionProjection 对 top-level 与 nested diagnostic 分别处理,native child lanes 在只压缩嵌套诊断时保持原样。

  6. loopx/presentation/renderers/quota_markdown.pyexamples/codex-subagent-orchestration-contract-smoke.py

    CLI 现在分别呈现主 orchestration 与 peer_activation_diagnostic 的 scope、state、selection、capability、blocker 与 required detail,避免 operator 从一个笼统的 lane count 推断执行权威;文档 smoke 改为断言替换后的句子。

对主干的风险

没有发现新的 blocking finding。本 head 之前的风险点(文档 smoke 与文档不一致)已在同一 head 修复。

  • 相关 Python 全路径:58 passed(含 quota → envelope → Turn 集成断言、默认关闭隔离与 Markdown 读回);
  • peer admission / TurnEnvelope / agent-context TypeScript:30 passed(含 50-task 压缩、top-level/nested、签名漂移);
  • npm run typecheck:control-plane:passed;Ruff、python -m mypygit diff --check origin/main...HEAD:passed;
  • loopx canary premerge --from-git-diff --git-diff-base origin/mainpassed selected=16 failures=0
  • full-public 套件中与本 PR 相关的 44 个 smoke:44/44 passed,含 codex-subagent-orchestration-contract-smoke.pytask-orchestration-smoke.pysubagent-status-projection-smoke.py
  • rebase 一致性:effect_runtime_handlers.ts 相对 main 只有预期的 +5/-0tests/test_turn_machine_credential.py 相对 main 只有本 PR 的断言改动。

已知与本 diff 无关的本地红灯:npm run test:control-planetests/control_plane_ts/sqlite_capacity.test.ts::small capacity entrypoint exercises real SQLite and never claims a full qualification 在本机失败(ledger row matched_profile_execution),我在干净的 origin/main checkout 上复现了完全相同的结果,属于机器性能/rehearsal 环境差异,CI 中通过。

语义与 CI 对齐

这个 PR 是对现有 vocabulary 的扩展,不是另起一套 actor lifecycle:peer_agent_activation、adaptive multi_subagentbound_delegation 仍由各自 owner 决策;runtime_readiness 只描述 probe,readiness/preflight 描述委派准入;execution_scope 明确限定每个合约的作用域。代码、双语文档、provider revision v5、旧 consumer、focused suites 与 full-public smoke 在本 head 上已经对齐。

剩余非阻塞风险:外部若把 delegation route 的 readiness 当作 execution admission 消费,需要改读 runtime_readiness(仓库内唯一此类 consumer 已迁移,两个 producer 也都新增了 execution_scope/preflight);multi_subagent.coordinator contribution 版本从 v4 升到 v5;本轮没有做真实 provider worker launch,因为该 PR 的边界是 read/projection/admission semantics。

我的整体评价

本 head 既完成了要求的冲突解决,也闭合了 rebase 暴露出来的文档契约回归,而且没有用「改掉失败断言」掩盖问题:smoke 改为断言替换后的等价句子,machine-credential consumer 已迁移,peer 决策从 Python 收敛到既有 TypeScript owner 而不是新增第二套权威。

authority placement、default-off isolation、domain-neutral wording、guidance-vs-obligation 与大列表预算处理都符合现有架构;net Python 代码减少,未来向重构做在了正确的边界。我对本 exact head 的结论是 APPROVE,并据此执行 owner 授权的自合并。

English verdict: APPROVE - head e44a44b resolves the conflict against current main (only the effect_runtime_handlers import overlapped; both sides kept), moves peer admission into the typed effect boundary while preserving canonical tasks and entrypoint independence, separates delegation runtime_readiness from execution readiness, compacts large peer inventories without dropping gates, and repairs the full-public documentation smoke; validation passed (58 Python tests, 30 TypeScript tests, tsc, Ruff, mypy, diff check, canary premerge 16/16, 44/44 matching public smokes), with the only local failure pre-existing on main.

@huangruiteng
huangruiteng merged commit 4bed6ed into main Sep 22, 2026
30 checks passed
@huangruiteng
huangruiteng deleted the codex/delegation-route-projection-20260921 branch September 22, 2026 06:00
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.

1 participant