Skip to content

Preserve complete context in shared quota diagnostics - #7557

Merged
huangruiteng merged 2 commits into
mainfrom
codex/quota-diagnostic-owner
Oct 28, 2026
Merged

huangruiteng merged 2 commits into
mainfrom
codex/quota-diagnostic-owner

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

Quota diagnostics used to drop unknown lists and retained-item fields, shorten portfolio text and hide candidate context. This PR preserves those facts and replaces the duplicated Python Todo-list reducers with one TypeScript owner used by should-run and the complete status/plan batch.

The reviewed head also introduced an unrelated numeric round-trip regression. Diagnostic replies now carry only display edits and references to the original input; Python applies those edits to its own facts. This preserves 1.0, negative zero, large integers and relocated upstream metadata. The existing Markdown renderer and its consistency assertion remain unchanged.

  • Basis: the controller C1 shared-owner requirement and the existing Turn diagnostic protocol.
  • Base: main; qualified against 90b26f2fa26835d668f4f1fb77dea87c81fda755 after rebasing the original proposal.
  • This is an independently usable diagnostic slice. WIP: converge governed work inputs and packaged heartbeat consumers #7430 retains native source/capture integration, writer cutover and complete C1 qualification.

Author Declaration

Written by OpenAI Codex, GPT-6 family model agent.

Criterion Delivered behavior and evidence
Preserve necessary context Unknown lists, fields, versions and complex nested values stay complete; visible items, candidates and portfolio prose retain their original content.
One decision owner diagnostic_projection.ts owns known Todo-list presentation. Python only transports and applies the typed edits. All status/plan rows share one request.
Preserve original numeric facts Cross-runtime edits retain source values instead of returning the entire payload through JavaScript numbers; nine precision cases fail on the previous implementation and pass after repair.
Keep canonical read behavior The existing read codec's content_revision is known display metadata; visible records keep it, and known diagnostic lists can still be compacted.
Preserve explicit detail and authority Full Todo details bypass diagnostic transport. Reference-only callers keep their historical wire contract. File/SQLite canonical Todo, provider revision and state bytes remain unchanged; read-only commands produce no heartbeat receipt or spend.

This is an internal projection helper. No capability, provider, scheduler, permission or storage owner is introduced. The local path-edit type has one active transport consumer; it contains no selection or compaction policy.

Scope And Continuation

Complete author implementation for this diagnostic slice. The original C1 remains open. Keeping this PR separate allows adoption or rollback without the native writer cutover in #7430.

Intentional output changes retain formerly hidden candidates, portfolio prose and unknown item content. The crowded unit fixture previously reached 43,862 characters because of that useful retained information; this is not a performance win or a change to public interface budgets. Status/plan adds one coarse projection request relative to the old local Python reducer. Agent/vision detail still needs one when User context remains compact; explicitly expanding both Todo roles skips it. The repair adds no request. It still sends the input and constructs an independent Python result; no end-to-end latency, model-token or long-horizon benefit is claimed.

Bounded refactoring applied: keep list decisions in the shared typed owner and preserve original facts in the transport adapter. Broader context-codec and consumer convergence remains with C1.

Validation

Tested revision: eb4e9b970aeb1ffb83e46705d6386cc3a4679ead. Synthetic/public fixtures and isolated real File/SQLite authorities.

Check Result
Focused Python projection and real CLI 105 passed, including the original compact/full Markdown tests on File and SQLite, unknown/nested fields, all detail combinations, one batch request and unchanged input.
Affected context, capture, decision, recovery and settlement callers 200 additional cases passed.
TypeScript envelope, context delivery and interaction 99 passed; no failures or skips.
Static and publication boundary TypeScript typecheck, Ruff, staged bilingual check, diff hygiene, semantic advisory and public/private scan passed.
Exact-scope change quality Passing receipt for all seven changed paths at this head.
Standard premerge Passed: six direct checks and 14 selected checks, with no failures or manual holds. The first run held on a missing exact-scope quality receipt; the completed run verifies the passing receipt.

Historical failures are retained: the original 5b5d9dd and its rebased equivalent both fail the two File/SQLite Markdown cases. All nine new source-number cases fail before repair, including a large integer whose value was rounded. The first edit-transport attempt failed on aliased caller objects and the reference-only hash contract; separating JSON objects and retaining that existing contract resolved those failures. No original consistency or content-preservation assertion was removed or weakened. The original earlier run's obsolete zero-request expectation is still documented by the existing explicit-detail transport test.

Independent review and protected merge remain separate pending stages. The earlier REQUEST_CHANGES review is historical evidence; author tests do not replace a review of the new head. No CI query/wait, merge, install, release, model run or paid benchmark was performed.

Frontend / Visual Evidence

UI impact: none. Existing CLI/model diagnostic readers retain their entrypoints; no screen, setting or frontend capability is added. Visual evidence: N/A.

Type / Area / Boundary

Bug fix, refactoring and bilingual protocol/test update; control-plane presentation. No storage migration, provider routing, permission, scoring or release change. Both commits retain DCO sign-off. Public/private scans exclude local state, raw traces, credentials and local paths. No paired RFC changes.

@loopx-agent loopx-agent 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.

Reviewer: model_agent — gpt-6.1-sol / OpenAI; runtime_reported; effort=max

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

动机 / Motivation

使用 quota should-run、status 和 plan 阅读工作与候选条件的 Agent 或维护者,会遇到摘要丢失原始条件的问题。一个候选的尾部停止条件或新增列表在旧摘要中消失;当前 head 保留其完整内容,已知冗余列表仍有带遗漏数量的详情入口。这避免靠新 guard 重取另一个时刻的状态来补读旧条件。本切片不交付 controller 原生消费者、统一准入或安装采用,也未证明模型和完整成本净收益。

24 个同输入真实 CLI 反例均从 base 失败转为 head 通过;扩展回归仍发现 status/plan 的 Markdown 详情一致性失败。当前仍须修复 Markdown 数值显示差异;controller C1 消费链与同 capture 接续仍属于现有 #7430。

改动思路 / Approach

共享 typed owner 删除重复 Python 裁剪,已通过当前 CLI 证明实用增量;整个 status/plan payload 的数值显示兼容缺陷仍须修复。原调用链先计算权威决定并保存 capture,再通过既有 reference_context 操作做纯展示投影。新模块只识别既有诊断列表,未知字段、复杂内容与新版本保留全文,原有选任务、claim、lease 和结算 owner 均未替换。一次操作处理整批行,避免每个 Goal 各加一次 bridge 调用。

不修改会保留已复现的数据丢失;只在 Python 补规则又会与后续 native 路径各维护一套。当前共享边界合理,但它不能因此改变无关的数字显示。当前 PR 只交付共享诊断投影;C1 原生消费者及统一契约切换沿 #7430,不能以本 PR 的通过数量宣告整体完成。

具体改动 / Changes

完整审阅 base 19c213324fbb5990288bd374c1b79096f22bb152 到 head 5b5d9dd3b0a816aae9d5160b849cff4a3c38da13 的 7 个路径(+290/-346)。3 个生产文件移除旧 Python reducers、接入现有 TypeScript 操作并增加 128 行诊断投影;3 个测试文件覆盖保留内容和批量调用,协议双语说明默认变化及额外传输成本。

关键代码讲解

  • knownItems 复用 canonical Todo field contract;未知版本、字段或嵌套复杂值不会被当作普通诊断条目删除。
  • compactSummary 只对已知列表执行限量,保留条目全文、原有 source_projection 与遗漏数量;不根据有界列表推断权威状态没有其他任务。
  • projectQuotaDiagnostics 在一个请求中处理所有 status/plan 行及 next_automatic_turn。候选集合、portfolio 正文和当前工作来源保持完整。
  • _reference_context 复用既有 bridge,但现在整个 plan 会被 JSON 往返;这正是下面数值显示差异进入原 Markdown renderer 的位置。

规范依据为 docs/reference/protocols/turn-envelope-v0.md,不可变版本 19c213324fbb5990288bd374c1b79096f22bb152:required-work-context 的完整来源与原准入边界已保留;Portfolio v2 的候选次序、条件及结算规则保持;Large todo summaries 的已知诊断详情入口仍可用;C1 caller replacement 仍由既有 #7430 承接,不冒充当前已交付。新增文档澄清旧详情读取当前状态,不能恢复历史决定,这个边界准确。

对主干的风险 / Risks

[P2] 保持 compact 与 full-detail 的数字显示一致

默认行中的 compute 是 Python 浮点数 1.0。新 status/plan 调用 让整个 payload 经过 TypeScript JSON 编解码,回到 Python 时变为整数 1;显式展开两类 Todo 则绕过该请求。因而同一个完整观察经过两种展示路径,分别出现 compute=1 和 compute=1.0。这里没有证明额度大小或执行权限改变;问题是此次纯诊断重构破坏了既有 Markdown 读回一致性,而且遗漏了受影响的实际测试。

独立在不可变 base 上运行 python -m pytest -q tests/control_plane/test_quota_plan_observation_payload.py -k real_cli_compact_and_full_detail_preserve_canonical_todos:PASS,2 项。同条件当前 head:FAIL,File/SQLite 各一项,均停在第 92 行的 compact/full Markdown 比较。最小修复是在既有投影/renderer 边界保持两条路径一致,再重跑这两项及内容保真检查;不需要重做准入或降低权威/正文断言。

语义与 CI 对齐

本次复用既有 Todo/诊断词汇,没有新增持久化状态、权限或业务专用规则。当前 shared projection 仍有上述未披露显示差异,因此 observable semantics 不能记为等价。远端 CI 按当前规则未查询、未轮询、未等待;本结论来自本地不可变 base/head 的实际比较。

本地扩展检查为 304 passed / 2 failed;两败均是上述回归。TypeScript envelope、interaction、context-delivery 97 passed,类型检查通过,standard premerge 的 6 个直接检查及 14 个选中检查通过。另有 24 个同输入真实 CLI 案例,旧版全部丢失相应上下文、head 全部保留;canonical task、provider revision 和零扣额断言成立。未来字段只在真实决定生成后的展示边界注入,未用 mock 直接给出修复后的 postcondition。最初测试路径及私有夹具自身的 claim_scope 假设错误已更正,两版本原失败记录保留,不归因为产品问题。

我的整体评价 / Verdict

这是一项有用且可独立回退的共享诊断改进,完整上下文与 Python 重复规则删除都得到实证;但当前准确 head 的 Markdown 兼容检查仍失败,应先完成该窄修复再批准。长程执行权限、任务与结算保持,完整运行成本和实际模型收益仍未证明。status/plan 新增一次 RPC、输出保留更多正文是明确成本,不能把代码减少或测试数量当净效率收益。

视觉审阅不适用:检查的是 CLI JSON/Markdown 与 TypeScript 投影,没有前端渲染或图片改动。原生 C1 消费者、正式安装 App 和模型采用仍未验证。当前源码判断为 REQUEST_CHANGES;未执行合并、安装或任何 CI 操作。

English verdict: REQUEST_CHANGES at 5b5d9dd; the context-preservation repair is verified, but compact/full Markdown parity regresses on both File and SQLite.

if isinstance(payload.get("next_automatic_turn"), dict):
result["next_automatic_turn"] = project_row(payload["next_automatic_turn"])
return result
return _reference_context(payload, task_title=False, explore_guidance=False, diagnostics={

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.

[P2] 这个新增的整包 TypeScript JSON 往返会把原 compute=1.0 变成整数 1,而显式 all-detail 绕过该调用,导致同一观察的 Markdown 读回不一致。现有 test_quota_plan_observation_payload.py::test_real_cli_compact_and_full_detail_preserve_canonical_todos 在不可变 base 19c213 两个 backend 均通过、该 head 两个均失败于第 92 行。请在既有投影/renderer 边界保持两种展示一致,并重跑这两项;无须改变任务、权限或完整正文断言。

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@loopx-agent
loopx-agent force-pushed the codex/quota-diagnostic-owner branch from 5b5d9dd to eb4e9b9 Compare October 28, 2026 11:32
@huangruiteng
huangruiteng merged commit 4b2b97b into main Oct 28, 2026
9 of 10 checks passed
xiaoan17 pushed a commit to xiaoan17/loopx that referenced this pull request Oct 28, 2026
…servation

loopx-project#7557 preserved capability candidate collections on the hot-path projection.
The real-CLI budget fixture re-measures the same `quota should-run` workload
at 24,925 -> 25,836 JSON characters for the multi-agent scenario (+911),
which exceeds the unchanged 25,500 ceiling.

Markdown is unchanged at 6,439. Small (23,265 against 25,000) and crowded
(35,836 against 42,000) stay inside their ceilings, the per-Todo allowance
(300 chars/unit) and the fixed semantic allowance (9,700) still cover
crowded-minus-small growth, and every other surface ceiling is untouched.

Raise only this ceiling to 27,000 and record the base/head measurement at the
spec. The original overflow remains a recorded failure, not a reclassified
pass. Runtime payload size and production transport limits are unchanged.

Validation: tests/control_plane/test_cli_output_budget.py 38 passed, 1
skipped; ruff clean.

Signed-off-by: xiaoan17 <anbc1224@gmail.com>

@loopx-agent loopx-agent 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.

Reviewer: model_agent; model=gpt-6.1-sol; provider=OpenAI; runtime_reported; reasoning_effort=max

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

已合并版本的独立 post-merge audit:eb4e9b970aeb1ffb83e46705d6386cc3a4679ead;整项 PR 的不可变 base:90b26f2fa26835d668f4f1fb77dea87c81fda755。下述结论评价当前源码和原 P2 的修复,不替代合并前本应完成的评审,也不撤销历史讨论。

动机 / Motivation

使用 quota should-run、status 和 plan 阅读工作条件的 Agent 或维护者,需要看见当前候选和原始限制。

旧摘要会删除未知列表、条目的新字段和候选内容;即使当前任务能执行,后续选择仍可能依据不完整条件。

当前版本保留这些内容,并修复完整与紧凑视图的数值差异;真实 File/SQLite 对照保留了原始数值和规范工作。

本切片只交付诊断展示,不交付统一 controller 切换、安装采用或模型与完整成本净收益。 C1 的原生生产者、同 capture 消费链与整体收益资格仍沿既有 #7430,不能由这次诊断审计结清。

改动思路 / Approach

展示规则集中到既有 TypeScript 边界,Python 只应用编辑并保留原始数值;这删除了重复决策,而没有增加状态 owner。 当前 PR 只改变 should-run/status/plan 的纯诊断投影;准入、Todo、claim、lease、capture 和一次结算仍归原 owner。

不改会保留已复现的内容丢失;继续给 Python 加 allowlist 仍需维护两套规则;整包经过 JavaScript 再返回则无法保留 Python 的数值表示。当前边界复用既有 reference_context 粗粒度调用,让 TypeScript 决定展示,Python 从原始输入应用编辑。这里没有新增配置、provider、状态库或执行阶段。

沿现有 CLI 解析、真实 canonical read/guard、共享投影和单独 readback 走过正反路径。全详情仍可直接读取,status/plan 的整批行只加一次请求。历史 detail 命令读的是当前状态,不能假装恢复旧观察;这个限制在中英文协议中有明确说明。

具体改动 / Changes

完整读取七个路径,+425/-349:三个生产文件 +230/-283,三个测试文件 +159/-66,协议说明 +36。相邻重构已应用:删除 Python 的摘要、portfolio 和 capability-candidate reducers;没有通过新 wrapper 保留第二套选择规则。

关键代码讲解

  • contextProjectionChanges 生成原始输入引用和展示编辑;不是把原始数字从 JavaScript 再编码回来。引用始终指向未变的输入,数组删除从尾部执行。
  • compactSummary 复用 canonical Todo 字段,只压缩已知诊断列表;未知 schema、字段或复杂条目保留全文。保留项的 content_revision 和上游 source_projection 也保留。
  • _apply_context_projection_changes 先分离 Python 别名对象,再从原始事实应用编辑,保持 1.0、-0.0、大整数及嵌套值。非法路径/形状拒绝,旧 reference-only 调用仍返回原 wire/hash 形式。
  • compact_quota_plan_cli_payload 让所有 groups 与 next_automatic_turn 共用一次调用;显式展开两类 Todo 时跳过该投影。现有 quota dispatcher 是实际生产 caller。

规范依据是 docs/reference/protocols/turn-envelope-v0.md,spec_revision:90b26f2fa26835d668f4f1fb77dea87c81fda755。没有把本 PR 新加的说明当自己的独立 oracle:required work context 的完整来源/未完成读取保留;Portfolio v2 的候选次序、条件与结算语义保留;Large todo summaries 的诊断详情边界保留;C1 的 producer/consumer 切换与整体基准仍 deferred 于既有 #7430。base RFC 明确允许当前 caller 已采用、能独立验证和回退的 prerequisite。

对主干的风险 / Risks

未发现当前阻塞性问题。 原评审 5680770581 的数值问题在重基后的中间版本 edeb4fb8368f6a50d1e23f1c2896ec27ef48cf1b 仍复现:File/SQLite 都在原第 92 行比较失败,出现 compute=1 与 compute=1.0。不可变 base 两项通过,当前 head 两项通过;renderer 和原一致性断言均未改动。修复不是只改显示字符串,而是阻止无关原始事实经历有损往返。

独立验证为 105 Python tests PASS、99 TypeScript tests PASS、typecheck PASS。另用同一组冻结值跑真实 File/SQLite CLI 的 should-run/status/plan 与 compact、Agent、User、all-detail 组合:base 6/24 内容 oracle 通过、head 24/24 通过。未来诊断只在真实决定后的展示入口注入,没有 mock 投影结果或 backend postcondition;完整条目、未知嵌套、原始数值、上游元数据和输入不变均检查。规范 Todo/provider revision/状态字节未变,只读命令零 guard receipt,guard 场景保留每次原 receipt,全部零扣额。

真实成本不能省略。同一 56,401 字符 fixture 的紧凑输出由 33,205 增至 43,862,恢复了原先隐藏的 12 个 runnable、8 个 blocked 和8个 binding;完整视图仍为56,401。这里调整的是有内容价值依据的测试回归断言,没有放宽公共硬上限。status/plan 增加一次 batch RPC;仍有整包输入与 Python 结果副本。未据此宣称端到端延迟、token 或长程效率提升。

语义与 CI 对齐

新编辑类型属于单一 co-deployed adapter 的临时传输;诊断版本和 Todo 字段复用既有 owner,不产生新的权限、actor lifecycle 或持久化词汇。未知值保留策略避免用 prose/suffix 猜测义务。diff-scoped advisory 未发现支持的新词汇载体,完整 semantic check 通过;这不等于证明所有动态语义。该历史 head 自带的 standard premerge 6 direct +14 selected PASS,七文件 public-boundary scan 干净。按配置未查询、轮询或等待 CI;没有执行 merge、dismiss 或安装。

我的整体评价 / Verdict

APPROVE 当前有界诊断修复;delivery 判断为 justified_increment。long_horizon 为 preserved:原工作、权限、后续接续和结算身份没有变化,未来条件不再丢失;user_experience 为 improved:沿原命令即可看见完整条件和一致数字,不增加配置或确认回合。这个判断来自真实 caller 和反例,而不是测试数量或代码行数。

视觉审阅不适用:变化位于 CLI JSON/Markdown 诊断和跨语言投影,没有网页、App 视口或图片改动。 未验证真实模型采用、已安装 App/Lark 或长程净收益;本评审也不提供追溯性的合并授权。

机制与问题相称,原 Python 重复规则已删除;保留旧 reference-only wire 有现有消费者依据。C1 整体切换和实际收益继续保持开放,不以本次 post-merge audit 追认先前合并流程或宣告父目标完成。

English verdict: APPROVE — eb4e9b9. The complete diagnostic slice and original numeric regression are independently verified with 24 matched real File/SQLite CLI cases, the unchanged Markdown oracle, 105 Python/99 TS tests and passing local risk checks; C1 cutover and net-benefit qualification remain separate.

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