Repository navigation
fix(selection): use canonical admission across quota consumers - #6268
huangruiteng merged 2 commits into
Conversation
Signed-off-by: song <liusongstep@gmail.com>
Signed-off-by: song <liusongstep@gmail.com>
songoow
left a comment
There was a problem hiding this comment.
Reviewer: model_agent | GPT-6 | OpenAI | self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机
Agent 在同一轮选择 Todo 并准备执行、写回和结算时,需要可靠的准入结果。此前旧的交付标志为真时,即使正式通道拒绝执行或没有交付权限,待选任务仍可能被接纳;被拒绝的选择也可能带着扣费或旁路执行标志进入后续读取。当前分支拒绝这些矛盾输入,同一输入下合法生产输出和读取结果保持一致,恢复命令仍可在同一轮重新检查。
本 PR 校验当前选择的一致性,不验证 Goal 身份、租约真实性或外部执行授权,也不声明安装端或真实模型验收。#4447 的全量来源证据、Goal 方向与恢复、团队两轮闭环仍由各自既有验收负责;本批不关闭这些范围。
改动思路
复用现有 TypeScript work-items 边界与 Effect 传输,删除 Python 平行准入规则;候选发现、回执协调和最终读取各保留自己的职责。
本批把最终选择准入贯通到真实 CLI、交互构造和类型化读取,保留同 Turn 恢复及合法例外;不引入状态存储、配置开关或权限缓存。
验收依据是基线 43173c0b8c8761abee4cdddc665f0f0f20f194f7 的 docs/status-data-contract.md 正式交互协议(primary interaction protocol),以及 docs/quota-allocation.md 的选择/重新准入要求(selection recovery)。复用当前 owner 比单独修 CLI 更能避免消费者分歧;无需迁移整个 scheduler 或候选发现模块。
具体改动
关键代码
action_selection_admission.ts:23/44/85:统一最终准入、恢复和残留授权拒绝;待选交付要求正式 work/delivery 授权,待选修复要求明确修复路径和交付拒绝。回执绑定交还原协调逻辑。action_selection_contract.py:196与 CLI preflight:传递有界事实,保留 true/false/unknown;删除 Python 平行判定。interaction_contract.py:1694在一次构造中共用恢复结果,公开 CLI action 入口仍先检查。effect_program.ts、scoped_override.ts、should_run_packet.py和两个内部 read operation:在真实读取入口拒绝矛盾权限;新 Envelope 继承同一规则。primary_action.py:422拒绝非布尔权限,避免字符串 false 变成授权;相邻只读 predicate 改为Mapping[str, object],没有放宽维护预算。todos/identity.ts与 lease caller 仅共享 Todo 格式,分别保留 Python/JS 的空白与错误行为。三个回归文件覆盖权限反例、兼容注释、合法修复、回执例外及特殊空白;双语文档披露变化。
正例沿真实 quota/CLI → 正式通道 → TS 判定 → 原回执或恢复路径执行。固定输入下三类生产输出及合法 interpreter/Envelope 完整结果与基线一致。反例中,三种正式权限拒绝/缺失和八种残留权限读取从错误放行变为拒绝;同 Turn 恢复 argv 保留。语义 advisory 无支持载体发现只是提示,不被用作等价证明。
对主干的风险
Exact head 5d79ce8e726705a6906e349b300f99ae03d8adcb:567 个 Python 用例通过、3 个失败;168 个 TypeScript 用例通过。TypeScript typecheck、premerge 的 10 个 catalog、8 个 risk 与 public-boundary 检查通过。相同实现另有 190 个 Python/架构/lease 用例通过;Ruff、配置范围 mypy 通过,显式检查既有未纳入模块时基线 120、当前 118 个错误,规范化对比没有新增诊断。语义与维护预算保持原上限。
三个失败是既有结算 CLI 的 fresh scheduler ACK:一个普通结算、两个 Todo-less replan 场景。相同命令在不可变基线和当前 head 都报 rrule_mismatch,宿主观察为空且未写 scheduler 状态;最新 #6259 要求当前宿主读回,而这些未修改的 fixture 没有提供。失败路径的宿主读取/ACK commit 未被本 PR 修改,选择/回执与恢复不变量另有独立通过证据。因此这是已归因的主干验证缺口,不能称全套通过,完整合入检查仍须处理。
新增桥接依赖按实际 request scope 测过:无 qualification 不新增选择 RPC,选中/拒绝路径每次交互构造一条投影。并发验证期间有时间波动,未证明速度提升或线上 SLO。没有状态迁移和 provider 事务改动,可回退本批两个提交;未验收安装 App/Lark 或真实模型。
我的整体评价
APPROVE 当前有界改动:它消除已复现的错误授权并保持合法请求的完整输出,规则归属和成本与问题相称。相邻简化已应用于共享 Todo 格式及只读类型,未增加未来框架。此结论不消除上述基线失败、远程 CI 或维护者合入授权要求,也不关闭父级语义与 Goal 验收。
English verdict: APPROVE - 5d79ce8. Canonical selection admission now rejects denied/unknown pending permissions and residual execution grants while preserving valid full outputs. 567 Python and 168 TS cases pass; three scheduler ACK failures reproduce identically on immutable base and head and remain a separate full-suite/merge hold. No merge or installed/live qualification is claimed.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent; model=gpt-6.1-sol; provider=OpenAI; runtime_reported; reasoning_effort=xhigh.
动机
同一轮选择 Todo 并准备执行、写回和结算的 CLI/Agent 调用者。
旧版本在正式通道拒绝或缺少交付权限时,仍可能凭旧的根级标志接纳待选任务;新版本拒绝这些矛盾输入,合法选择及同一轮恢复仍可继续。
CLI preflight、交互构造、Effect、TurnEnvelope 与 scoped override 采用同一准入规则;被拒绝的选择不能残留执行或扣费授权。
本批只校验当前选择的一致性,不验证租约真实性、Goal 身份或外部执行授权,不声明安装 App/Lark 或真实模型验收。
完整来源语义与安装/宿主采用仍由现有验收负责,#4447 保持开放。
改动思路
最终准入属于既有 TypeScript work-items 边界;Python 只传输事实,删除平行准入规则。语法复用和同次构造的一次恢复判定是有界相关简化,不能用单独修 CLI 替代所有当前消费者。
本 PR 交付当前选择从 CLI/交互构造到三个 typed reader 的一致准入和可执行恢复;候选发现、回执协调、租约与 provider 权限保留各自 owner。
接受契约先于diff读取:docs/status-data-contract.md,spec_revision 43173c0b8c8761abee4cdddc665f0f0f20f194f7。并对照同版本docs/quota-allocation.md的selection recovery条款;逐项核对 interaction_contract 的正式通道准入,以及 reenter_guard_without_selection 的原回执/同Turn恢复。
具体改动
评审exact head:5d79ce8e726705a6906e349b300f99ae03d8adcb;完整差异基线:43173c0b8c8761abee4cdddc665f0f0f20f194f7。
action_selection_admission.ts:23/44/85统一当前准入、恢复和残留授权拒绝;pending delivery 要正式 must_attempt 与 delivery_allowed 都为 true,workspace repair 要明确 repair 路径及 delivery_allowed=false,缺失权限保留 unknown。action_selection_contract.py:160/181/196仅传输有界事实/适配结果,删除Python平行准入;CLI preflight保留true/false/unknown,旧兼容注释不能独立grant或veto。interaction_contract.py:1719一次构造复用一次恢复判断,公开action入口仍先核验。Effect、Envelope(由既有解释器)及scoped override三种reader共用一致性检查。primary_action.py:422拒绝非布尔权限,避免字符串false变授权;Todo grammar提取到4行typed helper,分别保留Python strip和JS trim的既有差异。11个生产文件、1份双语文档、3个回归文件完整检查,共15文件+490/-106;没有新状态存储、provider事务、公开选项或权限缓存。
独立400行当前输入复核(20组调用上下文):正式权限false/unknown以及拒绝后残留work/spend/bypass/settlement均被真实preflight/TS Effect/Envelope拒绝;基线错300项。80行合法、无qualification及后来独立subject的完整输出与基线一致。作用域/旧兼容字段移除/archived receipt/同Turn工作区修复后的再准入,另由实际native CLI/File fixture验证。这些上下文不代表真实领域业务长期运行。
对主干的风险
当前299项Python和120项TS通过,typecheck、仓库范围Ruff及126项全树语义检查通过。3个native结算CLI ACK case失败,不能称全套绿:相同检查在不可变基线和head均有同一rrule_mismatch、空observed_host_rrule且不写scheduler;另一个旧回执ACK被正确拒绝为stale。实际完整ACK payload除fixture路径/派生effect_id外相等,相关测试、heartbeat_commit_cli.ts、heartbeat_commit.ts源码未变,选择不变量有独立通过证据。这是单独full-suite/merge hold,既有#6285是修复候选而非已合入资格;不要求本PR改无关scheduler。未读取/轮询CI。未验installed App/Lark、live model或整体SLO。
我的整体评价
APPROVE当前有界一致性修复,未发现本PR引入的阻塞。效果为正向:拒绝不能残留可执行授权,合法当前工作与恢复不被旧兼容注释否决。效率需要分开看:一次决策的代码归属更集中,但Python桥接路径实际更慢。30次warm样本的qualified构造中位数11.25→20.04ms,pending preflight约0.0014→9.27ms,各多一次selection RPC;无qualification路径为零新增selection RPC。接受这是约9ms的局部正确性成本,不宣传提速/长期净收益。相邻grammar和构造去重已应用;更粗粒度或原生TS调用可沿既有迁移owner继续,无需本PR新增cache/framework。
English verdict: APPROVE - 5d79ce8. Canonical admission closes reproduced false grants and preserves valid/recovery outputs.299 Python/120 TS and126 semantic cases pass; three independently identical baseline ACK fixture failures remain a separate merge hold. A measured warm bridge cost is disclosed; no speedup/live qualification.
A pending Todo could be admitted from a root delivery flag even when the canonical agent channel refused work or omitted delivery permission. Other quota readers could also accept a rejected/deferred selection carrying residual execution, spend, bypass or settlement authority.
This change puts final admission/recovery in the TypeScript work-items owner and uses it from CLI preflight, interaction construction, Effect interpretation, new TurnEnvelope construction and scoped override. Admission reads canonical channel permissions; compatibility annotations cannot independently grant or veto it. Malformed producer booleans now fail explicitly. Receipt reconciliation, exact current-work and workspace-repair paths remain, with one recovery decision shared within interaction construction. Todo grammar is shared while preserving each caller's whitespace/error behavior.
Validation at
5d79ce8e726705a6906e349b300f99ae03d8adcb: 567 Python cases passed; 3 scheduler ACK cases fail identically on immutable base43173c0b8c8761abee4cdddc665f0f0f20f194f7because their fixtures omit current host readback required by #6259 (rrule_mismatch, no scheduler write). This is an attributed baseline failure and remains a full-suite/merge limitation. All 168 affected TypeScript tests, typecheck and premerge (10 catalog, 8 risk, public boundary) passed. The same implementation also passed 190 additional Python/architecture/lease cases, Ruff and configured mypy; explicit touched-module mypy has no new diagnostics against base. Semantic drift and maintainability pass without ceiling changes.The same-input immutable base/head oracle preserves complete valid producer/reader outputs and rejects the intended contradictory cases. Request-scoped timing was measured and the added bridge paths observed; concurrent-check variance prevents a speedup claim. No state migration or provider transaction changes. Installed App/Lark and live-model qualification are outside this consistency slice.
This is a bounded part of the existing semantic convergence work, not closure of #4447 or the Goal recovery/team journey acceptance.