Repository navigation
refactor(quota): move task route override to TypeScript - #7292
Conversation
Signed-off-by: aihop <4408344+hhyykk@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent | gpt-6.1-sol | OpenAI | runtime_reported | reasoning_effort=max
APPROVE,针对 ff70dfac9715686f63317db8e1579e59dbe060f8。既有粗粒度 TypeScript owner 吸收并删除了一条 Python 重复规则,公开语义经独立对照保留。无新增阻断发现;required 失败及严格质量门继续保留。
动机
使用 task-scoped 协调和 quota should-run 的用户、Agent 与已有 CLI/Host 调用方。
基础准入已由 TypeScript 持有,但 ready 状态、task route 判定与协调提示仍在 Python 再判断一次;同一语义分散在两个实现。
ready 的 adaptive/peer 协调原先由 Python 修改已组装 hint;现在由同一 TypeScript 操作返回补丁,数量、说明和移除 worker action 的结果均保持。
1,944 组相同输入的全部旧判定字段与公开 hint 一致;十组真实 File/SQLite 同夹具 CLI 完整输出一致,且丢失 lane 数的两次公开入口 mutation 均被检出。
完成现有粗粒度判定中的一个重复规则删除;不代表整个 quota read transaction、整 Goal 迁移、性能收益、已安装 App 或真实长程成果资格。
required Ruff 五条旧诊断、一个旧 frontier 测试和旧 peer scanner 失败均保留;严格质量 FAIL/invalid_receipt,不能据本审查越过合并门。
改动思路
复用现有 quota.run_decision 请求返回 typed route patch;Python 只从已读来源投影 lane 数并合并结果。删除旧规则,不新增 leaf RPC、配置、provider 读取或持久化状态。
依据修改前已接受的 migration RFC,这次适合按「已有事务内完整迁移并删除规则」判断:不是新增一个 route-only 调用,也不是用 helper 数量冒充整个 quota 事务完成。补丁只修改已有 hint;来源数据、Guard、claim、lease、执行与 spend 权限仍归原 owner。
完成现有粗粒度判定中的一个重复规则删除;不代表整个 quota read transaction、整 Goal 迁移、性能收益、已安装 App 或真实长程成果资格。
具体改动
完整审查相对 a9a720db5ef77f52ac9a3c1e59be7df324149aa6 的十一文件 +177/-42:五个生产文件、四个测试/fixture 文件、两份 RFC checkpoint。全文 diff、实际调用者、讨论、DCO 与公开边界已核对。已有英语/中文 checkpoint 都明确保留其他 Goal route/action builders,以及先前 full-CLI p95 回退的 owner 复核门槛;成对 diff 检查通过,内容含义也已人工对齐。
原 RFC 无编号条款按审查映射为 existing-transaction-owner、observable-parity、source-fact-transport、bounded-checkpoint,均 implemented:同请求返回结果、旧 Python 判定删除、既有列表投影和实际公开消费对照分别给出证据。这些是映射标签,不是新注册需求。
关键代码讲解
-
taskOrchestrationRouteHint:在现有 TS 判定中检查 ready,并沿用 adaptive/peer 两种提示和来源 lane 数;等待状态不覆盖原 hint。
-
resolve_quota_run_decision:从已有 child 列表计数,非列表才回退 peer;沿用同一个粗粒度请求,再取出路由补丁并保留 Python 配额大数与元数据。
-
apply_task_route_hint_override:只合并返回补丁;私有 marker 为 true 才去掉 current_agent_next_action,marker 本身不进入公开 hint,其他字段保持。
-
inspectGoalAcceptance:有验收状态时复用 acceptanceTask 自带 todo_id;无状态时在既有 unbound 分支保留 key,删除重复投影。
对主干的风险
最容易漏掉的回归是「TS 判定没错,但最终公开 hint 少字段、保留竞争的 worker action,或协调说明变了」。因此没有只比较布尔值或让共享新规则的两个 provider 互证。
同一私有 harness 在不可变基线和精确 head 上执行 1,944 个组合,涵盖 None/空契约、falsy/带空白状态、ready/waiting/blocked、adaptive/peer/未知模式、child 优先与 peer fallback、空 hint、未知嵌套元数据、超过 JS 安全范围的 Python 原配额大数,以及更高优先级 guard。全部旧 decision 字段与公开 hint 一致,每次 facade 仅调用一次逻辑 quota.run_decision;此计数不是端到端性能或所有 provider 调用成本测量。
真实 File、SQLite 后端各验证关闭态、正常协调、缺少 spawn capability、阻塞子项、paused 五种公开 CLI 场景。随后在同一物理夹具和相同路径/provider revision 上重放两版入口,完整 JSON 一致;仅校验并规范化 projection 的观测时间/短暂 staleness 和 rollout event id/时间,null 时间仍保留,路由、诊断、action basis 及其他字段不动。通过同一真实公开入口故意删去 peer_lane_count 时,两种后端都只在独立 child-count oracle 上失败,恢复原实现则通过。首版规范化器误解析 null 时间,失败记录未作通过证据;修正后完整双臂重跑。
完整 TypeScript 为 5,487 passed /75 skipped,类型检查通过;七个 Python 模块未作 deselect,136 passed /1 failed。四个改动 Python 文件 Ruff、配置内 mypy17、required CLI 输出差分、精确 base/head 的 bilingual/diff 和公开扫描通过。Semantic diff advisory 在五个源快照中未发现受支持的新词汇载体;其 Enum/Literal/as-const 等覆盖限制仍存在,不代表已穷尽语义。
验收投影也经过真实隔离 PostgreSQL 17.11:369 个 store 检查与80个 File/SQLite/PostgreSQL 验收检查通过、零跳过;独立 service 连接配置下真实集成通过,该套件10 passed /1 无关占位检查仍 skip。首次 service 因专用连接变量未配置而跳过真实集成,保留为未资格化记录,未算通过;两次临时数据库均已移除。
语义与 CI 对齐
三类 required 红项均独立在 a9a720db5ef77f52ac9a3c1e59be7df324149aa6 和当前头复现,保留失败身份与完整细节:
- Ruff 五条 E701/E702,完整输出逐字节相同,全在未改的 attached-conversation 测试。
- frontier CLI 测试同样期待
reassignment_required却得到normal_run:夹具先把空 Todo 写入 canonical SQLite 并启用 fence,随后只向显示 Markdown 追加 prerequisite。两版都按同一个实际 canonical 来源读到空集合。完整 traceback 仅规范化 pytest 临时路径。 - premerge 的 peer runtime smoke 同样在 hard-cut 扫描器报
read_codec.ts:219的既有removed_continuation_policy诊断行;扫描器、被扫文件与嵌套报错完整一致,仅规范化源码根。它在本次路由消费前失败。
标准 premerge 六项 direct 通过、19项选中检查18通过,人工 hold 为0;剩下 scanner 失败及严格 cqr_39ab2809d87899f254c8 的 FAIL/invalid_receipt 令整体保持 quality_invalid_receipt。质量结果已补齐实际 skip 与 premerge 失败说明;没有把归因当成 required 豁免。APPROVE 判断本次有界迁移与独立不变量,不能代替这些合并门。未查询、等待或轮询 CI。
我的整体评价
交付为 justified_increment,long_horizon 与 user_experience 均 preserved:实证是同一公开语义、完整提示、错误/恢复和关闭态得到保留,而重复规则已删除。减少未来 drift 的结构收益合理,但没有实证宣称长程效果、完整成本或性能提升。
有界重构已落实到旧 Python helper 删除和 acceptanceTask 身份复用;无需新协议、缓存或独立设置界面。新增的 count/patch 是同包 caller/runtime 的私有派生传输,没有持久化语义迁移。其余 quota/Goal 事务迁移和性能资格保留给既有 owner;当前 required 红项和严格质量仍阻止直接交付合并。
English verdict: APPROVE at ff70dfac9715686f63317db8e1579e59dbe060f8. The existing coarse TypeScript operation now owns the task route rule and the duplicated Python decision is deleted. 1,944 complete decision/hint pairs and ten full public CLI pairs on real File/SQLite preserve behavior; both deliberate public-entrypoint dropped-count mutations are detected. Real PostgreSQL17.11 store/acceptance and enabled service integration passed. Unchanged required lint, frontier-fixture and peer-scanner failures were independently reproduced and remain failed; strict CQR/premerge remains invalid. No whole-transaction, performance, installed-product, long-horizon benefit or merge authority is claimed.
Motivation
The accepted migration RFC is in its transaction-payoff phase and calls out the remaining quota route/action builders. This slice moves the task-scoped route override into the existing
quota.run_decisionTypeScript request. It removes the duplicate Python route decision without adding a bridge request.Implementation
quota.run_decision.task_goal_route_hintdecision is deleted.goal_route_hintshape and wording remain unchanged. No provider read, authority, write, or cross-runtime request was added.todo_idproperty in the Goal acceptance inspection projection, which blocked TypeScript typechecking. Its task IDs remain covered by an assertion.Validation
npm run typecheck:control-plane: passed.npm run test:control-plane: 5,486 passed, 0 failed, 76 skipped (5,562 total).pytestquota decision plus semantic quota witness: 62 passed.ruff checkon changed Python files: passed.Performance and compatibility
A local in-process comparison ran 30 batches of 5,000
quota.run_decisioncalls per revision, including JSON serialization. Median latency was 0.68 µs at the base and 0.96 µs at the candidate, an absolute increase of 0.27 µs per call. This microbenchmark does not represent full CLI latency. No full CLI A/B claim is made. The request count stays unchanged.Known baseline issue
tests/control_plane/test_agent_scope_frontier_contract.py::test_cli_should_run_reads_disposable_state_and_emits_v1expectsreassignment_requiredbut receivesnormal_run. I reproduced the same failure with the worktree stashed at unmodifiedorigin/main; this slice does not change that frontier decision.ruff format --checkreports reformatting across the existing compact formatting in the four touched Python files. No unrelated whole-file reformat is included.