refactor(frontier): unify typed revision and long-chain replan policy - #4258
Conversation
huangruiteng
left a comment
There was a problem hiding this comment.
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
复核 exact head:1fe18bb3c52f4082ff8c355962c26a3a20b33b17
动机
这个 PR 的动机成立:advancement frontier revision、long Todo-chain threshold 与 ACK/rearm 目前仍由 Python 持有较多决策规则,会在 TypeScript control-plane 迁移期形成双重 authority。目标是保留 Python 对 legacy Todo 字段的归一化和精确 v0 JSON codec,把 lane selection、完整性、hash、15/20 阈值和 exact ACK 判断集中到 TypeScript。
改动思路
实现沿用了现有 effect_runtime_result 边界。Python 将 canonical Todo row 编码成稳定 facts,TypeScript 的 projectAdvancementFrontier 负责 all/unclaimed/by-agent index,evaluateLongTodoChain 负责 threshold 与 ACK;Python 再适配回现有 tuple/dataclass 接口。这样没有引入新持久化或 CLI,也删除了旧 Python 决策体。特别值得保留的是 excluded-only Agent 的显式 lane:它避免该 Agent 错误 fallback 到包含被排除工作的 global unclaimed checkpoint。
具体改动
- 新增
frontier_revision.ts,集中 row decode、checkpoint、index、threshold 和 exact ACK 规则。 - Python
frontier_revision.py只保留 legacy field serialization、normalization 和 response adapter。 long_todo_chain.py将 observe + ACK classification 合并为一次 typed request,保留 freshness timestamp fence。- handler 注册新 effect operation;中英文 RFC 记录迁移后的 authority boundary。
- 测试覆盖稳定 hash、排序/时间戳无关性、excluded lane、duplicate fail-closed、15/20 阈值、exact ACK 和 material rearm。
关键代码讲解
loopx/control_plane/todos/frontier_revision.ts:63的checkpoint统一 eligibility 与 material identity;duplicate id 或 invalid timestamp 都返回 incomplete。loopx/control_plane/todos/frontier_revision.ts:132的evaluateLongTodoChain保留 15 advancement / 20 open-with-advancement 两个阈值,并只接受 exact checkpoint ACK。loopx/control_plane/todos/frontier_revision.py:99的build_advancement_frontier_revision_index是 Python→TS adapter,也是当前唯一阻塞点。
对主干的风险
当前有一个确定的 P1:build_advancement_frontier_revision_index 在 line 102 直接返回 _request(...)["index"]。该 subscript 的类型是 Any,因此新 adapter 没有兑现声明的 dict[str, Any] 边界,required mypy 报:Returning Any from function declared to return "dict[str, Any]" [no-any-return]。我用同一 scoped command 比较了 exact base/head:base 通过,head 稳定失败,所以这是 branch-attributable regression。
最小修复:先把 index 绑定到局部变量,验证 isinstance(index, dict);不满足时在 adapter 边界抛出包含 typed frontier response 上下文的 TypeError,满足时返回已经 narrow 的 dict;再加一个 typed runtime 返回非 object index 的回归用例。这样既让 mypy 通过,也把 malformed response fail-closed 在正确边界,而不是延迟到 summary consumer。
验证方面,4 组 focused Python suites 为 65 passed in 19.04s,direct TypeScript tests 为 7 passed,npm run typecheck:control-plane 通过;Hosted DCO、build、Node compatibility、Windows 和全部 Stage2c 通过。test shard 3 的 completed-todos HTTP 503 位于本 PR 未改动路径,我把它记录为独立 residual,不用它阻塞本结论;deterministic mypy regression 已足够要求修改。
我的整体评价
迁移方向、rule ownership、兼容 codec 和 negative cases 都合理,且 production 净减行,future-facing pass 不需要再扩一个抽象层。当前只需把 Python adapter 真正做成 typed/fail-closed boundary,并补 malformed response 测试。修复后重跑 scoped mypy、focused Python/TS suites 和 required checks,即可按新的 exact head 复审完整 PR。
English verdict: REQUEST_CHANGES — the TypeScript authority migration is well-scoped and semantically convincing, but the new Python adapter returns Any as dict[str, Any], fails the required mypy gate on this exact head, and needs explicit response decoding plus malformed-response coverage.
Signed-off-by: huangruiteng <huangrt01@163.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
1fe18bb to
e2a0eed
Compare
Review follow-up — both regressions fixedFinal head:
Product and architecture judgmentThe PR removes duplicate Python lane/revision/ACK decisions while preserving the v0 codec. Excluded work and ambiguous identities have explicit documented fail-closed corrections; thresholds, timestamp-only maintenance and terminal relevance remain covered. The transport companion change fixes an actual installed-user read path, not speculative infrastructure. No new provider, promotion, write authority, optional capability or UI behavior is introduced; existing CLI/status/history consumers benefit through the same owner. No additional broad refactor is warranted. Final validation and merge decision
Decision: owner-authorized self-merge/admin bypass after the above risk-based validation; the identical baseline budget failure and pending hosted CI are explicitly disclosed, not waived as passing tests. No installation requested. |
Summary
Ownership and compatibility
Existing core Todo/frontier policy is the owner; no new capability, provider, storage transaction, writer or promotion route. The companion transport codec follows the existing compressed-facts pattern without introducing a general transport framework. Encoded requests retain the shared 2 MiB limit; decompression rejects invalid input or output above 64 MiB. Small requests remain plain facts.
No frontend change is necessary: completed-history HTTP and quota consumers keep their existing contracts. No claim, lease, user authorization, settlement, provider CAS/replay or optional-capability enablement changes. This closes one T3 consumer rule group, not the entire TS migration or shared-authority RFC.
Validation
Exact head:
e2a0eedbc5ca152f575c157e046e214555f58eed; base:37ca93ff7f4ea204f5c3eeb4f0bf910c0ec5d4f3.npm run test:control-plane: 1,245 passed, zero skipped, including disposable real PostgreSQL 16 and file/local conformance. Temporary server stopped afterward.dashboard_status_jsonbudget failure is identical on immutable main and final head (18,930 > 18,500). It is disclosed, not relabeled as success or addressed by increasing the budget.cqr_7f6a28db49e0853f9af4, verified valid for 12 changed files. Scope fingerprint:7f6a28db49e0853f9af4b533137fbe5afd7629bddb914ccbc15c1304df8cce9b.request_too_large; it now passes. A complete frontier larger than 2 MiB preserves the independent exact v0 digest and detects a tail-row material edit.Shared fixture impact: existing production-scale coordination fixture plus a complete-timestamp/unclaimed-exclusion variant covers checkpoint selection and rearm. New transport regressions complement it with long text, large complete source identity and invalid encoded inputs. No provider routing or promotion changes; snapshot replay is not a three-provider cutover qualification or performance claim.
No model-token qualification or live installation is claimed. Earlier hosted failures must not be represented as passing: the mypy failure and HTTP failure are both fixed here, not waived as environment noise.