Skip to content

refactor(todos): compose canonical quota sources and bound responses - #8302

Open
cocolord wants to merge 10 commits into
mainfrom
codex/small-kernel-todo-projection-20261107
Open

cocolord wants to merge 10 commits into
mainfrom
codex/small-kernel-todo-projection-20261107

Conversation

@cocolord

@cocolord cocolord commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Canonical Todo query/selection responses lost their ephemeral source recipe before quota preparation, so Python resent complete source and separately encoded selection/resume rows. The quota projection now retains validated native sources and shares one complete provider read through the existing TypeScript Todo owners. Agent summary/planning/terminal views and the User summary are explicitly composed; standalone displays retain their existing view.

Selection/resume materialization follows actor/profile/clock binding. Complete source digests, incarnation, revision, cursor and replay recipes preserve provenance. Provider diagnostics, independent caller metadata, scalar/list/tuple distinctions, legacy fnmatch, lane precedence and distant microsecond clocks remain intact. Transformed rows retain the supplied-source codec. Vision-wait basis reuse requires matching actor, complete terminal rows and logical request identity.

The previously reviewed large-response regression is also repaired: the 8,000-row composed quota bundle at e7db1711f serialized 13,080,176 bytes and caused 13,080,177 bytes of synchronous response-snapshot writes. The existing read adapter now losslessly gzip-encodes quota results above the original shared 8 MiB inline budget and within the existing complete-frame budget. Its result-piece protocol binds encoding and decoded extent; the Python adapter rejects unknown encoding, truncation, trailing members and extent/digest changes. Larger reads retain their original paging. The same diagnostic now emits 561,291 wire bytes with zero response-snapshot writes and complete independent-view parity. This single diagnostic does not prove acceleration.

Validation applies to final PR head 2ca24f42754d838fa285eadebc090131ca86e5bf, with production code 2c9d6360e, based on target main@8a4d4f9da:

  • Four fresh complete 101-Todo source/isolated-wheel × File/default-SQLite CLI lifecycles pass. A separate verifier accepts sum=45; original completion time, four receipts, one debit, Effect restart, invalid Vision/workspace refusal, evidence-replacement refusal and settled replay remain intact. The built wheel matches the affected source files.
  • Final response/source-binding coverage passes 36 Python cases; two additional native File/SQLite 8,000-row quota cases compare the complete three views with their independent prior paths, preserve both role sources and provider data/revision, and produce no response snapshots. Twenty-two TypeScript context/quota cases and eight real receipt/replan/reentry cases pass. Original transaction coverage of 132 Python and 86 TypeScript cases is retained; incremental tests cover the final transport change.
  • Real disposable PostgreSQL 16.15 passes 391 store and 11 service cases with zero skips, including native source composition, complete metadata, zero provider writes and stale-reference refusal. PostgreSQL source/wheel host CLI acceptance remains open.
  • TypeScript typecheck, Ruff, the maintainability ratchet, paired RFC gate and public-boundary file scan pass. The shared response budget reuses its existing owner/value; gzip is a co-deployed IO protocol extension. No new persisted state, lane vocabulary or provider authority is introduced. Wider schema consolidation remains outside this change.
  • Final standard premerge passes all six direct checks and 18 of 19 selected checks. The remaining failure is peer-agent-runtime-v1-smoke.py, whose hard-cut scanner also fails on immutable main against unchanged benchmark documentation. Mypy retains main’s missing return annotation at decision_capture.py:659; both remain validation holds. The public-boundary file subcheck passes; the full loopx check reports six pre-existing canonical-authority errors in unrelated Goal registrations, which are not changed or waived here.

Five new interleaved unprofiled default-SQLite source pairs compare the same complete 101-Todo fixture/outcome on main@8a4d4f9da and production 2c9d6360e. Both inherit normal bytecode conditions; no heavy tests run concurrently. Daemon CPU uses the independently calibrated macOS Mach timebase 125/3, and cumulative daemon CPU/writes subtract each initial fixture baseline.

Observation, median unless stated Main Proposal
Lifecycle wall time (range) 13.894 s (12.686–16.481) 14.974 s (14.131–15.344)
Fixture setup / final teardown 2.347 / 0.062 s 2.299 / 0.062 s
CLI child + observed daemon CPU after setup 7.086 s 7.403 s
Observed daemon disk / logical writes after setup 8,884,224 / 13,795,328 B 10,076,160 / 15,130,624 B
Daemon boundary physical footprint 141,032,832 B 150,520,728 B
CLI maximum resident size 71,467,008 B 71,696,384 B

Four candidate runs are slower, and wall-time ranges overlap. The large-response write regression is removed; whole-path acceleration and complete marginal-cost benefit remain unqualified. CPU excludes unsampled provenance/restart helpers, final daemon exit and harness CPU. Separate RSS/footprint observations are not a continuous system peak. Model cost, human attention and installed-host/long-horizon adoption are unmeasured.

Correction to historical evidence: the earlier 66ff8bf48 versus main@e2371c476 CPU values 5.511/5.757 seconds used an invalid Mach-unit conversion. Raw historical observations remain unchanged. Correct conversion yields 7.071/7.469 seconds including setup daemon work, or 6.706/7.107 seconds after removing the initial daemon baseline. Those historical pairs already failed to demonstrate whole-path benefit. The bilingual RFC marks the original CPU row invalid and preserves every frozen failure.

Independent exact-head review, CI/readiness and explicit maintainer merge authorization remain required. The original complete transaction/benefit acceptance stays open: I3 for at least one minor release, M1/#8011, full R0/V10/R1, D2/D5/D6/D3, context/model/split-install and adoption/full-cost gaps are retained.

中文:本提案把完整 native 来源 recipe 保留到实际 quota 路径,在 actor/profile/clock 绑定后复用既有 TS owner,并在一次请求内共享完整 provider read。大 quota 组合响应现在经原传输 owner 无损 gzip 编码,8,000-row 诊断的 response snapshot 写入从 13,080,177 字节降为零,完整字段及独立展示语义保持一致。最终源码/wheel 的 File/SQLite 四条完整生命周期、真实大响应及 PostgreSQL 391/11 用例通过;反例、原完成时间、四份回执、一次扣款与重启恢复均保留。

新五组默认 SQLite 整轮墙钟中位数 13.894→14.974 秒,校准 CPU 7.086→7.403 秒,四组候选更慢;修复大响应写入并未证明整体收益。旧 CPU 5.511/5.757 秒因 Mach 单位换算错误明确标为无效,历史 raw 数据和失败不改写。完整收益与剩余验收保持开放,继续独立复审和原路径成本归因。

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewer: model_agent | gpt-6.1-sol | OpenAI | runtime_reported | reasoning_effort=max

动机 / Motivation

使用 LoopX 托管工作的人需要在一次调度里看清要做的任务,并在进程重启后从原任务继续。以前,同一次调度如果要读取待办摘要、执行计划和已结束任务,会把同一批任务数据多次传给投影进程。新实现可以传一次数据就取得三个结果;只需要一个结果的调用也会被打包,本次复现了额外计算和写盘。这次改动处理视图传输;任务存储、领取、权限和结算仍沿用原来的规则。

完整来源事务和端到端成本验收仍待完成;本 PR 可以先把复用限制在确实要读多种视图的路径。

改动思路 / Approach

复用完整来源的方向成立;打包范围应由知道要读取哪些视图的调用方决定。本次边界是一次托管请求中的 Todo 展示传输,已保存的 Todo、权限和结算仍由原有组件负责。 在实际 guard 中,Python 先拿到当前完整任务数据,再以完整 JSON 和传输选项在本次请求内识别可复用的结果。TypeScript 原投影函数仍解释任务状态;按任务 ID 寻找运行结果的调用方仍只取它要求的那一种。记录、权限和结算来源不经过这个缓存。优先让现有 quota 组装逻辑选择要读的视图,保留其他调用方的旧路径,可以交付这部分复用,不必等待整个来源事务重构。

具体改动 / Changes

关键代码讲解

  • effect_runtime.py:1622:在已固定运行时版本的请求中,只要来源和选项符合形状且输入不超过约 2 MiB,就把请求替换成三个视图。缓存键包含来源和选项;命中后重新解码,避免一处改动影响另一处。三种返回缺任何一项都会在写缓存之前失败。
  • context_projection.ts:35:按原 TypeScript 函数分别生成摘要、计划和保留终态。只有摘要使用已清除交接门禁;未改变记录类型或权限解释。现有 project_delivery_response(delivery_history.py:93)只请求 retained terminal,却会收到三个完整数组后丢掉另外两个。
  • 七个文件中,运行代码为 +49/−2;测试 +161,双语 RFC +103。最后一次更新增加配对的后续设计说明和 PostgreSQL 快照组合测试。现有单视图路径仍供大来源和非托管请求使用,File/SQLite 的持久记录和重放身份沿用原来的代码。

规范基线:docs/architecture/rfcs/monorepo-distribution-split-v0.md,修订 94b91e48aa4a2cdafe9d4d31d918fe84d0112b41。I2 已实现:保留原任务权限、投影和结算 owner。I8 已实现于本次对照的完整来源、门禁及原凭证路径:来源更新和下一次请求重新读取。I9 已按本切片落实:分开报告数据量、执行环境和范围。V10 / R0 的完整默认 SQLite 成本资格仍待验证。

对主干的风险 / Risks

[P2] 单视图读取会计算并写出两个无人消费的视图。 同一真实投影调用、相同 8,000 条开放 Todo 和继承关系,运行一次 retained terminal 读取。基线请求 1,128,077 B、响应 3,728,136 B,走套接字;候选请求 1,128,078 B,计算三套各 8,000 行,落盘并同步一个 11,184,165 B 的私有快照。最终投影哈希相同。只让该调用保留旧的单视图请求后,候选又返回 3,728,136 B,不再写快照。 写盘分支沿用既有校验,也会同步文件;输入小于 2 MiB 并不能保证三个结果都能留在 8 MiB 的套接字响应上限内。即使留在内联上限内,单视图也会承担其他两套计算。同机 Node v24.21.0、CPython 3.14.8,warm broker,每臂 5 次无传输探针计时:8,000 条 retained 视图中位数 0.216→0.835 s;15,000 条短记录 0.232→1.478 s。这是单个源码调用的诊断,不外推为整个 CLI、后端或长程收益。

保留通用单视图入口,把打包放到明确同时消费多种视图的组装调用方;继续由原 TypeScript 投影 owner 执行。增加仅消费一种视图的实际 transport 对照,并在默认 SQLite 路径同时核对请求、响应、临时文件和回执。

复现时,在基线与候选分别启动隔离的本地 Effect 进程,构造 8,000 条开放 Todo:ID 按 todo_build_00000 编号,每条短正文,successor_todo_ids 指向下一条。将其作为 {"items": rows},在 effect_runtime_request_scope() 中只调用一次 project_delivery_response(首条 Todo,delivery_outcome="outcome_gap",outcome_followthrough_required=True)。记录该次 todo.context.page 的响应和 _read_local_snapshot_response 收到的 result_ref.byte_count。对照路径仅给现有单视图源加对该分支无影响的 strip_text=False,从而跳过新打包条件;保留相同最终结果,并核对快照读没有发生。

验证 观察
PASS · 实际 File/SQLite 领取、校验、归档及恢复 源码 CLI 对同一 101 条 Todo fixture 的 File/SQLite 基线与候选四组均通过:一次独立校验、一次写回、一次扣额;四种原结算凭证和完成时间可恢复,已确认原 Effect 进程退出、新进程重放、替换证据被拒。
PASS · 多视图的预期收益 同一 101 条 Todo guard 的参数 JSON:File 841,869→726,162 B;SQLite 842,360→726,653 B;均 82→80 次调用,加载 503 模块不变。
FAIL · 仅消费一种视图 真实 Effect 返回保持相同;额外输出触发约 11.18 MB 私有文件写盘。
PASS · 回归与源码检查 前一提交的 242 项 Python 和四组实际 CLI 生命周期覆盖的实现、测试与依赖在新提交中逐字不变;新提交重跑 16 项批处理测试、60 项 TypeScript(含 56 项聚焦投影测试)和实际写盘复现。 类型检查、Ruff、双语 RFC 和差异检查通过。改变来源、交接门禁、调用方修改返回值、大来源、独立请求和缺失视图都有覆盖。
UNVERIFIED · PostgreSQL 最新提交新增 PostgreSQL 原生快照组合测试;本机没有隔离 PostgreSQL,测试加载后跳过,作者的数据库证据未独立复跑。
UNVERIFIED · 托管 CI 和独立安装 本轮采用源码验证,未查托管 CI。

语义与 CI 对齐

新键只在共同发布的 Python 和 TypeScript 间传递读视图,复用原 Todo 状态和权限语义;没有新持久状态、额外的执行授权或新的提示义务。大来源、不在请求 scope 的来源和其他投影模式仍走原路径。本轮的阻塞点是默认打开的投影工作量;现有测试通过不能排除这个回归。

我的整体评价 / Verdict

多视图复用减少了同一真实 guard 的调用与输入字节,且在 File 和 SQLite 的配对案例中保留了原任务、完成时间、回执和重启后的继续条件。单视图路径增加了等待和同步写盘,用户得到的内容相同,因此当前提交仍需修改。建议保留现有单视图通道,在明确需要多个结果的调用点打包,并重跑两种负载和原结算验证。本次改动位于托管 CLI 和共用 Todo 投影的内部传输层,没有改动页面布局。未运行已安装 App、真实模型、完整默认 SQLite 成本对照或长期采纳试验。

English verdict: REQUEST_CHANGES for 7f85fce90ece3263626c0f1b099a8f01869f2d1a. Keep one-view reads on the existing transport and bundle only at callers that request multiple views.

Comment thread loopx/control_plane/effect_runtime.py Outdated
size = MAX_REQUEST_BYTES
# Reserve space for all three results under the existing ceiling.
# Larger sources retain their original single-view transport.
if size <= MAX_REQUEST_BYTES // 4:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] 只读取一个视图时保留现有通道。 同一真实投影调用、相同 8,000 条开放 Todo 和继承关系,运行一次 retained terminal 读取。基线请求 1,128,077 B、响应 3,728,136 B,走套接字;候选请求 1,128,078 B,计算三套各 8,000 行,落盘并同步一个 11,184,165 B 的私有快照。最终投影哈希相同。只让该调用保留旧的单视图请求后,候选又返回 3,728,136 B,不再写快照。 保留通用单视图入口,把打包放到明确同时消费多种视图的组装调用方;继续由原 TypeScript 投影 owner 执行。增加仅消费一种视图的实际 transport 对照,并在默认 SQLite 路径同时核对请求、响应、临时文件和回执。

@cocolord
cocolord force-pushed the codex/small-kernel-todo-projection-20261107 branch from 7f85fce to c926f56 Compare November 7, 2026 17:29
@cocolord cocolord changed the title refactor(todos): reuse complete source display views per managed request refactor(todos): compose display views at the quota caller Nov 7, 2026

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewer: model_agent | gpt-6.1-sol | OpenAI | runtime_reported | reasoning_effort=max

动机 / Motivation

使用 LoopX 托管任务的人需要在一次调度内获得下一步,并在验收要求更新后继续原轮次。原 quota guard 会把同一个任务来源分别传给摘要、计划和保留终态的投影。新提交在常规小负载减少传输,但一条原轮次恢复路径中断,另一条合法输入路径新增了同步写盘。本切片仅交付展示传输的复用,沿用现有 Todo 存储、领取、权限和结算规则。

后续还需把同一次来源读取和默认 SQLite 的端到端成本作为独立验收。当前增量先补齐原轮次恢复与结果侧传输边界。

改动思路 / Approach

quota 调用方知道实际消费的视图,适合在此集中复用来源,并复用已有的回执上下文与独立视图。本次边界是 quota guard 中的 Todo 展示传输与已有的续跑输入,TypeScript 继续负责投影语义。 Python 选取一份当前来源,按明确的三视图请求交给原 TypeScript 投影。摘要使用现有交接门信息,计划和保留终态沿用各自的选择规则。既有请求缓存仍按完整输入区分,返回形状验证通过后才复用。单视图回读的复验通过,旧问题在本提交已解决。

具体改动 / Changes

  • quota 组装显式请求三种视图,并把保留终态传给 frontier。带原回执的备用分支在恢复当前上下文时也需要这份终态。见 quota frontier 与 原回执分支。
  • TypeScript 复用三个已有视图,拒绝混合请求。Python 验证返回的三组对象,通用单视图继续用各自的请求形状。见 视图分派 与 返回形状验证。
  • 五个运行文件共 +81/−13,三个测试文件 +243,双语 RFC +188。与当时主干的合并模拟保留相同的十文件净改动。

按基线 dee54966327e09406b3f7b17d155b03cd633b234 的 docs/architecture/rfcs/monorepo-distribution-split-v0.md 核对。I2 的投影与结算所有权沿用原路径。I3 的独立视图与大请求回退已对照。I8 的原轮次恢复未满足。I9 的本次证据分别列出入口、负载与响应。V10 / R0 的默认 SQLite 完整成本仍待验收。 已接受的 RFC

对主干的风险 / Risks

[P1] 原重规划回执恢复引用了已删除的变量。 实际 CLI 先得到 autonomous_replan_required 和一张原轮次回执。补充验收要求并关联等待中的后续工作后,基线 8 例全部恢复,新提交 8 例均在第二次 should-run 返回 quota_unexpected_collection_error。File 和 SQLite 的诊断复跑各保留一张原回执,扣额仍为零,CLI 无法交付该轮次的继续信息。 当原 obligation 仅带结构化复核类型和停止条件时,attach_receipt_replan_context 仍求值 replan_todo_items。在候选进程内只替换这一个参数表达式的对照中,File 和 SQLite 各恢复原身份、通过现有完整用例,读回原轮次的唯一扣额。 把 agent_todo_terminal_source_items 同时传给 attach_receipt_replan_context,并用 File、SQLite、stride 开关和并行 vision gap 的八个既有用例复验原身份、验收信息更新和一次结算。 备用分支

复现命令

uv run --extra test pytest -q tests/control_plane/test_quota_settlement_cli.py::test_replan_reentry_after_outcome_work_refinement_keeps_original_turn

[P2] 合并视图触发原先可内联的同步写盘。 在源码 quota 组装入口给相同 8,000 条带 successor 链的合法 Todo,基线三个 3,728,136 B 结果各自内联。候选把 1,128,293 B 请求合并,结果越过 8 MiB 上限,写入并同步 11,184,165 B 私有文件,再由 Python 读回。准入结果指纹相同。同一候选仅恢复三个已有视图调用,仍得到相同结果,三个响应各自内联。 让 quota 批处理同时遵守结果侧的传输预算。可能越过内联上限时沿用独立视图或按有界结果分组,用相同来源检验视图结果和实际快照次数,保留已恢复的单视图通道。 批处理分支

用 8,000 条 open/agent Todo,短正文并给每项一个 successor_todo_ids 环链。将完整 items 和首项放入 agent_todos 的状态源,在 effect_runtime_request_scope 下调用 build_quota_should_run,记录 todo.context.page 的请求、返回长度和私有结果文件。在候选只替换 quota 调用点为原三个 selector,比较结果指纹与落盘次数。 实际 SQLite 源码 CLI 的另一个 5,201 条短记录场景,请求约 2.23 MB,超过批处理输入上限。基线、候选及独立视图对照均内联,得到相同调度结果,扣额为零。 8,000 条案例使用合成的完整状态与真实本地 Effect,验证的是传输路径。

本地验证 观察
通过 · 普通 CLI 生命周期 101 条 Todo 的实际源码 CLI 进行 File/SQLite 基线与候选四臂对照。普通领取、校验、归档、写回和进程重启后读回通过,原四种结算回执保持一致,每臂各一次校验、写回和扣额,替换证据被拒。
通过 · 小负载传输 同一 101 条 fixture 中 guard 调用均从 82 降至 79。参数 JSON 在 File 从 841,863 降至 716,856 B,SQLite 从 842,354 降至 717,347 B。加载模块数均为 503。
通过 · 旧单视图问题 仅查询 retained terminal 的实际 Effect 对照中,8,000 条带链接记录在基线和候选均为 1,128,077 B 请求和 3,728,136 B 内联响应,结果指纹相同,快照次数均为零。
失败 · 原轮次恢复 基线 8/8 通过,候选 0/8。工作流范围 Ruff 指向同一未定义名称。
失败 · 合并结果传输 8,000 条配对案例新增 11,184,165 B 同步文件。
通过 · 其余检查 90 项聚焦 Python、10 项其他回执恢复用例、40 项 TypeScript、类型检查、双语 RFC、语义 diff 与标准 premerge 通过。
待独立验证 本地缺少隔离 PostgreSQL,新增的实际 PostgreSQL 快照组合测试加载后跳过,作者的数据库结果未独立复跑。 已安装客户端、真实模型和完整默认后端成本也未覆盖。

语义与 CI 对齐

展示类型和权限判断沿用原有 owner,当前改动影响准入前的传输与原回执的恢复输入。标准预检通过后,既有的八个实际 CLI 用例仍可独立复现恢复回归。本轮未查询托管 CI。

我的整体评价 / Verdict

本提交恢复了单视图传输,在普通 File 和 SQLite 场景里减少了 guard 调用。原回执仍须在验收工作链接变化后继续。先恢复终态输入,再把批处理限定在响应可以有界传输的情形,并以两种存储的原轮次用例和大结果配对验证修复。

English verdict: REQUEST_CHANGES for c926f5602f6b2826496dd735b99e0c1fc553b0a0. Preserve receipt-bound replan recovery and bound the quota bundle's response transport.

user_todo_summary=user_todo_summary,
agent_todo_summary=agent_todo_summary,
agent_todo_source_items=replan_todo_items,
agent_todo_source_items=agent_todo_terminal_source_items,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P1] 给原回执的恢复分支传入同一份终态。 删除本地来源后,下面 attach_receipt_replan_context 的 todo_items=replan_todo_items 仍引用旧名。实际 CLI 先得到 autonomous_replan_required 和一张原轮次回执。补充验收要求并关联等待中的后续工作后,基线 8 例全部恢复,新提交 8 例均在第二次 should-run 返回 quota_unexpected_collection_error。File 和 SQLite 的诊断复跑各保留一张原回执,扣额仍为零,CLI 无法交付该轮次的继续信息。 在候选进程内只替换这一个参数表达式的对照中,File 和 SQLite 各恢复原身份、通过现有完整用例,读回原轮次的唯一扣额。 把 agent_todo_terminal_source_items 同时传给 attach_receipt_replan_context,并用 File、SQLite、stride 开关和并行 vision gap 的八个既有用例复验原身份、验收信息更新和一次结算。

"planning": todo_planning_source_items(value),
"terminal": todo_planning_source_items(value, include_terminal=True)}
try:
result = effect_runtime_result("todo.context.page", request, large_local_snapshot=True)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] 把响应侧纳入批处理边界。 在源码 quota 组装入口给相同 8,000 条带 successor 链的合法 Todo,基线三个 3,728,136 B 结果各自内联。候选把 1,128,293 B 请求合并,结果越过 8 MiB 上限,写入并同步 11,184,165 B 私有文件,再由 Python 读回。准入结果指纹相同。同一候选仅恢复三个已有视图调用,仍得到相同结果,三个响应各自内联。 让 quota 批处理同时遵守结果侧的传输预算。可能越过内联上限时沿用独立视图或按有界结果分组,用相同来源检验视图结果和实际快照次数,保留已恢复的单视图通道。

@cocolord
cocolord force-pushed the codex/small-kernel-todo-projection-20261107 branch from c926f56 to 957bf0e Compare November 7, 2026 20:31
@cocolord cocolord changed the title refactor(todos): compose display views at the quota caller refactor(todos): compose canonical quota projection from one provider read Nov 7, 2026
cocolord and others added 8 commits November 8, 2026 05:07
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewer: model_agent | gpt-6.1-sol | OpenAI | runtime_reported | reasoning_effort=max

动机 / Motivation

使用托管 quota guard 的 Agent 需要选出当前任务,并在验收条件更新后继续原轮次。原 guard 对同一来源分别投影摘要、规划和保留终态。这个增量把查询和选择留下的来源信息交给既有 TypeScript 投影。实际 guard 减少了请求,原轮次重入也恢复了。本次改动沿用已有的存储、权限与结算规则。剩余问题是旧 asset 的兼容性、大结果的落盘和完整生命周期成本。依据是主干已接受的 I2、I3、I8、I9 以及 V10 / R0 的分阶段验收。 RFC

改动思路 / Approach

普通 guard 将 User 与 Agent 的来源引用交给同一次 Todo 投影。相同引用在一次事务内共享 provider 读取,store identity、revision、cursor 和完整字段摘要用来拒绝已变化的来源。TypeScript 沿用现有选择、恢复规划与视图投影。保留一次来源读取,同时把旧格式选择和响应边界交给现有的 owner。Python 继续组装调用和解码结果,原回执和扣额由现有生命周期处理。

具体改动 / Changes

  • 审查 e7db1711f8bbf317a0d28e910edb7705b8845e3b。实际改动 26 个文件,+1,644/−90。分支 diff 与对当前主干的干净合并结果一致,包含双语 RFC、既有 guard 的来源与传输改动,以及对应测试。
  • 上轮的原结算重入已修复。同一套 File、SQLite × stride × 并行 Vision gap 用例,基线和本提交均通过 8/8。四组实际 101-Todo 源码 CLI 生命周期保留校验、归档时间、四张原结算回执及一次扣额,进程重启后仍可读回,并拒绝替换已验收证据。 原回执分支
  • 8,000 条带 successor 链的独立展示,两边的结果指纹、3,728,136 B 响应与零快照一致。普通 SQLite guard 的 5,201 条对照也选中同一 Todo,实测 15→12 次 Todo RPC,请求 JSON 约 13.78→5.36 MB,均未落盘。 来源事务

对主干的风险 / Risks

[P2] 保留旧 project asset 的来源类型。 当顶层 agent_todos 和 project_asset.agent_todos 引用同一个旧格式对象时,source is canonical 会把优先选中的 asset 交给 canonical 摘要。用带一条合法 Todo 的旧格式 total="3", open="1", done="2" 复跑,基线及候选的等值复制对照都返回总数 3、完成 2。只有候选的共享对象路径将两项变成 null。只有 next 的旧格式输入还有准入差异,基线及候选的等值复制均拒绝缺少 Todo ID,候选共享对象返回可正常交付且没有选中 Todo。请让 selector 同时返回来源和投影类型,并对共享对象及等值副本复跑普通 guard。 来源类型分支

[P2] 给 quota 合并响应设定结果边界。 对同一隔离 SQLite fixture 的 6,401 条 Todo 执行源码 quota should-run,两边均选中同一任务且扣额为零。候选的 Todo 请求 JSON 从 16,939,228 降到 6,594,824 B,但两份 native reference 的 quota_projection 将三种视图和 wait basis 合成一个响应,新增一次 8,871,032 B 的私有快照写入、同步和读回。基线快照为零。此次观察覆盖传输和写盘,总延时仍待同负载对照。大输入回退测试走的是独立展示 helper,普通 guard 直接走 quota_projection。请保留一次来源读取,同时限制单个结果帧,按既有视图分段或复用同值行,并在 5,201 和 6,401 条相同输入下核对准入、响应和写盘。 批量结果组装

本地验证 观察
File / SQLite 生产入口 4 个实际生命周期,基线与候选各通过 8 项原轮次重入。147 项聚焦 Python、27 项冻结输出和 59 项 TypeScript 通过。
PostgreSQL 16.15 隔离实例 391 项存储和 11 项服务测试通过,零跳过。已安装宿主的完整 PostgreSQL 生命周期待验收。
变更范围检查 变更 Python 文件 Ruff、TypeScript 类型检查、双语 RFC、签署与公开边界检查通过。
仓库级检查 标准预检 6 个直接检查全过,18/19 项选择检查通过。未变的 peer 边界扫描在基线也失败。全范围 Ruff 的 4 条诊断和 mypy 的 1 条诊断在两边相同,仍是验证项。

完整生命周期的边际成本、已安装宿主和真实模型采用仍待独立验证。本轮按队列配置使用本地验证,托管 CI 未读取。

我的整体评价 / Verdict

新版本已恢复原轮次重入,并在实际 guard 中采用了来源引用。下一版需要固定旧 asset 的来源选择规则,并让大列表的结果传输可控。两个问题都有同输入的对照,修复后可用现有 guard 和已知任务结果复验。

English verdict: REQUEST_CHANGES for e7db1711f8bbf317a0d28e910edb7705b8845e3b. Preserve legacy asset projection regardless of object aliasing and bound the composed quota response.

source = _select_todo_source(canonical, asset)
if source is None:
continue
kind = "user" if source is canonical else "project_asset"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] 保留旧 project asset 的来源类型。 同内容的旧格式资产,基线和候选等值复制路径保留 total_count='3'、done_count='2'。候选共享对象路径两项为 null。只有 next 时基线及等值复制拒绝缺少 Todo ID,候选共享对象却返回 normal_delivery_allowed=true 且 selected_todo=null。 选择来源时同时返回投影类型,并核对旧格式共用对象和等值副本的摘要与准入。

const summary = requireJsonObject(request.summary_request, "summary request");
if (summary.consume_display_views === true) {
const display = {source: summary.source, handoff_gates: (request.handoff_items as JsonObject[]).map(row => row.display)};
wire.display_views = projectTodoContextPage({summary_display_views: display});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] 给 quota 合并响应设定结果边界。 6,401 条 SQLite 实际 guard,任务与扣额一致,Todo 请求 JSON 16,939,228→6,594,824 B。基线零快照,候选合并响应在私有文件写入并同步 8,871,032 B。 保留一次来源读取,为完整 quota 响应分段或复用同值行,核对结果与实际快照次数。

cocolord and others added 2 commits November 8, 2026 05:30
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
@cocolord
cocolord force-pushed the codex/small-kernel-todo-projection-20261107 branch from e7db171 to 2ca24f4 Compare November 7, 2026 21:41
@cocolord cocolord changed the title refactor(todos): compose canonical quota projection from one provider read refactor(todos): compose canonical quota sources and bound responses Nov 7, 2026

This branch has not been deployed

No deployments
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.

2 participants