Skip to content

Keep the complete quota Vision audit within the CLI budget - #9062

Merged
loopx-agent merged 2 commits into
mainfrom
codex/repair-complete-quota-cli-budget-20261119
Nov 22, 2026
Merged

loopx-agent merged 2 commits into
mainfrom
codex/repair-complete-quota-cli-budget-20261119

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Outcome

Complete Turn stores the Vision audit body once. The writer references its exact CLI view only when the full view matches. The existing capture reader restores the CLI clauses in the generated native first read, digest-pinned selections, field discovery, and verified native observations. The empty pointer returns the original signed source. A differing CLI obligation stays inline.

The matched 36-Todo, 12-run fixture used quota should-run --complete-turn --context-delivery off at base 02fd18df7fa119f21611646853b5d14d6448f15e and head 2c5dcf646061aae9dcc644963804b9bba63b0ea8. The measured characters and UTF-8 bytes are equal in this fixture.

Provider Current main Previous PR head Current PR head
File 61,034 59,052 58,982
SQLite 61,048 59,066 58,996

The previous PR head omitted required_before_closeout and the registry-read instruction from the generated native first read. Its saved-capture child selection failed. Both providers now restore the full CLI view, preserve the capture digest and fit the existing 59,000-character ceiling. The native navigation and initial reader outputs total 14,133 bytes on both main and the updated head. The 2,052-byte reduction is in the complete serialized decision.

同一组 36 条 Todo、12 次运行中,File 与 SQLite 的完整决策分别降到 58,982 和 58,996 字符。原生首读、摘要绑定的子字段读取及其观察回执均保留原有义务。

Local validation

  • TypeScript typecheck, 69 TurnEnvelope tests, File and SQLite regression fixtures, Ruff, bilingual RFC verification, and exact-file loopx check passed.
  • The capture-reader suites passed 286 tests. All six direct and 19 selected premerge checks passed.
  • The extended Python suite passes on the new base, including the Workbench CLI classification. The full TypeScript run had 6,732 passes and 91 skips. The unchanged digest-consumer fixture missing execution_loss_closeout_record.ts is its sole failure and reproduces on the base.
  • Goal change-quality receipt cqr_feeb5980057effc6acf3 retains the failed TypeScript validation, so merge qualification stays held for this head. Independent review is pending.

Authored by an OpenAI Codex model agent.

@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.2-sol · OpenAI (runtime_reported, max)

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

[P2] 原生选读漏交付 Vision 审核的必读步骤

在 File 和 SQLite 安装包上跟完 App 首读及剩余选读。主干送达 required_before_closeout 与 registry 读取说明。这个头只送达 required、continue 和根引用,既有 CLI 子路径选读返回指针缺失。通过同一捕获的根路径能读回原义务。 相关代码

动机 / Motivation

Codex App 和普通 CLI Agent 读 quota 当前工作契约,再判断 Vision 是否可以收尾。36 条 Todo 与 12 次运行的完整输出曾超过 59,000 字符。CLI 通道重复携带根审核里的多项义务。允许同一捕获复用完整审核。现有正常计划仍需送达原收尾条件和先读登记材料的顺序。本轮核验完整输出和原生首读接续。生产采纳、收费及跨平台安装仍需各自证明。

改动思路 / Approach

完整 Turn 先生成根审核。CLI 投影精确比较这一个 owner 的派生视图,再决定是否压成引用。原生选读仍按发布后的字段地址规划,新增引用缺少同一捕获的必读交接。四个路径涉及 TypeScript 完整包、协议说明与 Python、TypeScript 测试。根数据与已保存旧包均可读回。使用两份独立安装的 Core wheel,对同一规模的 File 和 SQLite 工作负载先度量完整正文。再用真实原生 SessionStart、首读、后续选读和错误摘要走一遍调用路径。

具体改动 / Changes

精确 head 9728962da36ed6d4658d5bef123eb214907343bf,diff base 5cfd6ae7d571f2f97da40982db23f76540723c89,4 个文件 +197/-121。逐项复核 same-fixture-full-body、original-capture-reader、planned-read-obligation。验收约定

关键代码讲解

  • cliVisionAuditView 从根 audit 取原 CLI 规则和 judge 字段。源码
  • requireVisionAuditReferences 校验引用作用域和候选字段的精确一致性。源码
  • referenceVisionContinuation 将同值 CLI 视图换为短引用。原生首读需要消费这一语义。源码
  • 既有渐进读计划发出 CLI 通道,复验必须同时覆盖其余选读和同捕获回退。源码

对主干的风险 / Risks

完整正文实测 File 60,964→58,968,SQLite 60,978→58,982,均保留 59,000 上限。普通完整包根审核和旧内联 capture 可读,错误摘要拒绝。App 在主干的首读与后续选读送达 registry 规则,候选只给 required 和 continue。向内联 CLI 子路径选读会令现有批次失败。显式改用同一文件的根路径可读回五条原义务。46 项 Python 通过、1 项跳过,103 项 TypeScript 通过。

语义与 CI 对齐

先查看登记材料,再做外部调研,是已载入审核的顺序义务。证据不足则保持 Vision 活跃。根审核保留这些条款。生成的渐进选读应沿同一摘要交付根路径,让 Agent 在依赖这项决策前按原顺序读取。预算数字只衡量完整输出。

我的整体评价 / Verdict

请求修改。保留现在的精确去重,把根审核安排进现有原生选读流程,携带原使用时机。用已安装 CLI 复测 App 的实读和补读,同时保留 59,000 字符上限与旧内联捕获回读。

English verdict: REQUEST_CHANGES. At 9728962, both installed backends fit 59,000 characters. The native selected read drops the registry-first closeout rule and the existing nested selection fails. The original root still reads successfully.

if (!shareCliView || path[1] !== "cli_channel" || !supportsCliVisionAuditView(owner)) return audit;
const view = cliVisionAuditView(owner);
const scopedReference = visionAuditReference(view, true);
return candidate === identity(view, ["vision_continuation_audit"]) &&

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.

完整包的同值去重通过预算。现有 App 原生选读仍请求 CLI 通道。File 和 SQLite 跟完正常首读与余量入口后均缺失原收尾步骤和先读登记材料的说明。请让现有渐进读计划在看到此引用时从同一摘要选读根 audit,带回原依赖时机。

@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 · Gemini · Google (self_reported)

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

[P2] 原生渐进读取与子路径选读未解引用 projection_view: "cli_channel",导致 Vision 审校必读指令丢失

在 File 与 SQLite 后端上以相同 SCENARIOS[1](36 条 Todo、12 次运行、include_agent_vision=True)对不变基线 5cfd6ae7d5 与本提交 9728962da3 做配对反事实实测:完整 JSON 输出确已成功压进 59,000 字符预算上限(File:60,840 -> 58,844;SQLite:60,854 -> 58,858),根路径 --select /vision_continuation_audit 也能正常返回全部字段(退出码 0)。但当开启 --codex-app --context-delivery on 走原生渐进读取(first_read_command + remaining_read_command)时,loopx/control_plane/quota/progressive_context.ts#L1168-L1178(initialContextReadGroups)仍然只选取 /interaction_contract/cli_channel/vision_continuation_audit 而未补选根 /vision_continuation_audit(实测 has /vision_continuation_audit=False),导致原生首读仅返回 4 个字段的存根 {projection_ref, projection_view, required, vision_gap_judge: {decision, done}},静默丢失 required_before_closeout、recommended_action、reason、registry_read_instruction、evidence_read_instruction、agent_judge_instruction、done_only_when、continue_when 与 otherwise;同时恢复子路径 --select /interaction_contract/cli_channel/vision_continuation_audit/required_before_closeout 从基线 rc=0(471 字节)退化为 rc=1(context_selection_missing_pointer)。请在 progressive_context.ts 中识别 projection_view: "cli_channel" / projection_ref: "$.vision_continuation_audit" 并同步调度选读根 /vision_continuation_audit,补齐 File 与 SQLite 原生渐进读回归测试。相关代码

动机 / Motivation

本 PR 面向在 36 条 Todo、12 次运行的 Vision 负载下执行 quota should-run 的 CLI 调度链路,以及依赖 --codex-app --context-delivery on 首读与后续选读获取 required_before_closeout 和 registry_read_instruction 等 Vision 审校约束的 Agent。改动前(5cfd6ae7d5),quota should-run --context-delivery off 在 File/SQLite 下分别输出 60,840 / 60,854 字符(超过 59,000 上限),但 --codex-app --context-delivery on 的原生首读与后续选读以及 --select /interaction_contract/cli_channel/vision_continuation_audit/required_before_closeout 都能完整拿回 required_before_closeout、recommended_action 与 9 个 vision_gap_judge 字段。改动后(9728962da3),--context-delivery off 完整响应分别降至 58,844 / 58,858 字符(稳定低于 59,000 上限),但 progressive_context.ts#L1168-L1178 仍只选取 /interaction_contract/cli_channel/vision_continuation_audit 而未补选根 /vision_continuation_audit,导致原生渐进读取仅拿到 4 个字段的引用存根并丢失 required_before_closeout 与 registry_read_instruction 等约束,同时既有子路径 --select /interaction_contract/cli_channel/vision_continuation_audit/required_before_closeout 返回退出码 1(context_selection_missing_pointer)。完整 JSON 预算目标已在 File(58,844 字符)与 SQLite(58,858 字符)两侧达标,根 /vision_continuation_audit 与旧内联捕获回读兼容保持完好;但 --codex-app --context-delivery on 原生渐进读取和子路径 --select 发生义务丢失,必须补齐读取端联动。本 PR 不调整 59,000 字符硬上限阈值,不更改 goal_frontier_projection.vision_continuation_audit 已有引用契约,也不修复基线既有的 test_quota_vision_audit_references.py 完整性哈希测试、test_vision_budget_cli.py wait 收尾测试或 maintainability ratchet 遗留告警。

改动思路 / Approach

在 TS 控制面既有拥有者 turn_envelope.ts 内复用 referenceVisionContinuation 消重是正确的架构归属(无需修改预算上限或增加 Python 并行规则);当前边界仅缺同一 TS 包内的 progressive_context.ts 消费端联动。完整 Turn 决策仍先以根 $.vision_continuation_audit 为单一真源,再在 composeCompleteTurnDecision(turn_envelope.ts#L2140)传入 shareCliView = true,用精确结构对比确认 cli_channel.vision_continuation_audit 与根完全等价后替换为轻量引用;未开启 shareCliView 的路径与历史内联捕获仍完整保留。

当前 PR 仅覆盖 turn_envelope.ts 生产端、单测与协议文档,尚未联动 progressive_context.ts#L1168-L1178 读取规划,必须补齐该边界后才可合并。不直接放宽 59,000 字符上限可以真实剔除同包重复文本,也不引入独立状态的同步负担;唯一的边界缺口是下游原生读取计划仍假设全部字段内联在 cli_channel 下,导致真实 --codex-app 调用链未能把引用解引用回根对象。

具体改动 / Changes

审阅基线为 5cfd6ae7d571f2f97da40982db23f76540723c89,精确提交为 9728962da36ed6d4658d5bef123eb214907343bf(4 个文件 +197/-121),依据协议契约 docs/reference/protocols/quota-cli-hot-path-compaction-v0.md(固定版本 5cfd6ae7d571f2f97da40982db23f76540723c89)逐项判定:

  • same-workload-cli-budget-ceiling:implemented — turn_envelope.ts#L2140 使 File/SQLite default_off 降至 58,844 / 58,858 字符(<= 59,000)。
  • complete-packet-and-default-off-parity:implemented — 根 /vision_continuation_audit 与旧内联捕获回读均完整保留。
  • native-progressive-read-obligation-parity:not_met — progressive_context.ts#L1168-L1178 未在 projection_view: "cli_channel" 场景下补选 /vision_continuation_audit,原生首读与子路径 --select 丢字段/报错。
  • protocol-projection-view-consumer-sync:not_met — 协议文档第 113–125 行与 turn_envelope.ts 一致,但下游渐进读取消费端尚未对齐。

关键代码讲解

  1. cliVisionAuditView(turn_envelope.ts#L533-L543):提取 required、required_before_closeout、recommended_action 与 9 个 vision_gap_judge 字段构成规范 CLI 视图,供消重前精确比对,避免字段语义被局部覆盖时误压缩。
  2. visionAuditReference(turn_envelope.ts#L549-L564):新增 cliView 分支,输出带 projection_ref: "$.vision_continuation_audit" 与 projection_view: "cli_channel" 的 4 字段存根,同时保持默认 goal_frontier_projection 引用结构不变。
  3. requireVisionAuditReferences(turn_envelope.ts#L583-L599):强校验 projection_view === "cli_channel" 仅允许出现在 cli_channel 路径且满足 supportsCliVisionAuditView(owner) 及结构完全一致,否则拒绝构造决策。
  4. referenceVisionContinuation(turn_envelope.ts#L601-L620、#L2140):composeCompleteTurnDecision 传入 shareCliView = true 执行就地视图压缩,但仅作用于生产者输出。
  5. initialContextReadGroups(progressive_context.ts#L1168-L1178,未随本 PR 修改):仍硬编码选取 ("interaction_contract", "cli_channel", "vision_continuation_audit"),未在 projection_view: "cli_channel" 出现时附带根 /vision_continuation_audit,成为原生读丢字段的直接触发点。

对主干的风险 / Risks

  • 回归触发路径与最小修复:见顶部 [P2];若合入当前 HEAD,所有启用 --codex-app --context-delivery on 的长程 Vision Turn 将在首读阶段失去 required_before_closeout 与先读登记材料/证据指令,且子路径 --select 失败。最小修复是在 progressive_context.ts#L1168-L1178 识别 projection_view: "cli_channel" 后把 /vision_continuation_audit 纳入初始/剩余读组,并在 File 与 SQLite 后端重测原生读取与子路径语义。
  • 本地验证实测:
    • tsc --project tsconfig.control-plane.json --noEmit(symlink node_modules 隔离下):PASS
    • TypeScript 测试:tests/control_plane_ts/{turn_envelope,context_selection,context_delivery,context_projection_root,diagnostic_projection}.test.ts 124/124 PASS;tests/control_plane_ts/{progressive_context,interaction_context_readback,context_source_identity}.test.ts 31/31 PASS。
    • ruff check loopx/control_plane/quota tests/control_plane/test_cli_output_budget.py:PASS;mypy(17 files):PASS;check_rfc_bilingual.py:PASS;loopx check --scan-path 公开边界扫描(4 files):PASS。
    • Python pytest:test_cli_output_budget.py、test_complete_host_request.py、test_turn_envelope.py、test_quota_vision_audit_references.py 共 153 passed, 2 failed,其中 2 例失败均位于 test_quota_vision_audit_references.py 的 test_real_guard_capture_and_recovery_preserve_vision_before_effects[file|sqlite](已在不变基线 5cfd6ae7d5 上复现同等 2 failed, 20 passed 与相同报错 EffectRuntimeRejected: complete Turn decision content integrity mismatch,属 pre_existing_unrelated);test_quota_cli_projection.py、test_progressive_native_context.py、test_vision_budget_cli.py 共 143 passed, 2 failed,2 例失败位于 test_authoring_example_material_closeout_has_no_missing_path_replan[file-wait|sqlite-wait](已在不变基线 5cfd6ae7d5 上复现同等 2 failed, 6 passed, 14 deselected 与 test_vision_budget_cli.py:315 相同断言失败,同属 pre_existing_unrelated)。
    • canary premerge:direct checks 4/4、python_compile 1/1、risk_profile_smokes 8/8、public_boundary 1/1、quota-plan/quota-work-lane-policy/monitor-scheduler-contract smoke 3/3 均 PASS;examples/control_plane/cli-output-budget-regression-smoke.py 在并行 premerge 争用下超时(175.444s),但独立复跑直接通过(cli-output-budget-regression-smoke ok);semantic-vocabulary-drift-smoke.py 在剥离 worktree 下缺 node_modules 失败,补齐临时只读 symlink 后 PASS;control-plane-maintainability-ratchet-smoke.py 对 2 个未修改历史文件报 advisory fail。
    • File/SQLite --context-delivery off(58,844/58,858):PASS;File/SQLite --codex-app --context-delivery on 原生渐进读取与子路径 --select 反事实:FAIL。

语义与 CI 对齐

cli_channel.vision_continuation_audit 新增 projection_view: "cli_channel"(属于扩展共享投影语义,未新增域专用或非类型化字符串规则),但共享协议文档与 turn_envelope.ts 已切换为引用视图,而 progressive_context.ts 仍按旧内联契约读取,构成 semantic_alignment 违例(violated),导致 native-progressive-read-obligation-parity 无法闭环。CI rollups 按目标配置不作阻塞依据(wait_for_ci: false)。

我的整体评价 / Verdict

当前评估为 fragmented,long_horizon 与 user_experience 均判定为 regression(observable_semantics 为 unintended_drift、semantic_alignment 为 violated、code_volume 为 necessary 且兼容性保留得当、change_proportionality 为 proportionate)。视觉审阅结论:仅变更 TypeScript 控制面上下文编排 turn_envelope.ts、协议文档与单测,不修改任何前端渲染组件或 UI 视图(未验证范围:无(纯 CLI / 控制面 JSON 投影契约改动,不涉及前端界面渲染))。请保留 turn_envelope.ts 精确结构消重与 <= 59,000 字符预算成果,补齐 progressive_context.ts 对 projection_view: "cli_channel" 的根 /vision_continuation_audit 自动选读并附 File/SQLite 回归测试后,再重新提交复审。

English verdict: REQUEST_CHANGES. At 9728962da36ed6d4658d5bef123eb214907343bf, default_off fits 59,000 chars on both File (58,844) and SQLite (58,858), but progressive_context.ts#L1168-L1178 omits root /vision_continuation_audit during --codex-app --context-delivery on progressive reads and --select /interaction_contract/cli_channel/vision_continuation_audit/required_before_closeout fails with context_selection_missing_pointer.

@mergify

mergify Bot commented Nov 20, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @loopx-agent.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 20, 2026
Keep the same-capture CLI view compact and restore its original fields in native first reads and digest-pinned selection. Verify provider parity and the existing output ceiling.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@loopx-agent
loopx-agent force-pushed the codex/repair-complete-quota-cli-budget-20261119 branch from 9728962 to 2c5dcf6 Compare November 22, 2026 06:47
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 22, 2026

@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.2-sol · OpenAI · runtime_reported · xhigh

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

动机 / Motivation

读取完整 Turn 或 Codex App 首读的 Agent,需要看到收尾前必须完成的核验步骤。 完整输出在根和 CLI 通道重复携带审核内容,超出既有预算。 前一版虽压减了包体,File 和 SQLite 的首读仍遗漏登记材料优先条款,直接读原 CLI 子路径失败。当前头保留节省,并在原命令中读回这些条款。 同一捕获中的根审核继续承担义务来源。CLI 子路径、首读和观察验证现可使用其原派生值。 范围是显式完整 Turn 的序列化及读取。普通 quota 路由不切换,实装采用和真实模型效果另行验收。

改动思路 / Approach

TypeScript 在发布前比较完整 CLI 视图,仅在完全相等时引用原根审核。Python 捕获读取沿用既有 CLI 投影函数恢复原值。 不新建持久 owner。先核捕获摘要,再将派生视图给显式选择和观察验证。整份原始内容仍按原摘要读回。 把压减放在同一完整包内,避免提高现有预算或把未知条款压成固定的几项摘要。某通道确有不同义务时保留其内联版本。

具体改动 / Changes

准确头 2c5dcf6,merge base 02fd18d,10 个文件,+232/-33。双语迁移账本、预算协议、写入端、读取端和两个测试面均按当前范围核对。 按修订 02fd18d 的现有规范核对各项要求。 目标规范

关键代码讲解

  • referenceVisionContinuation 在既有完整 Turn 组装中比较根和 CLI 视图,保留不同的原义务。 源码

  • context_vision_audit_view 在选择层验证同捕获引用,使用 cli_vision_audit_view 恢复 CLI 视图。 读取 · 投影

  • verified_context_selection 用恢复后的选区重新验证可归属的观察。空指针继续返回原始捕获。 原生观察

  • same-workload-budget 实测完整包体在两种存储均回到预算范围。

  • same-capture-read 保留原捕获空指针、摘要拒绝和原 CLI 子路径。

  • obligation-parity 登记材料优先、实际核验和收尾义务均读回。

对主干的风险 / Risks

File 完整输出 60,868→58,816 字符,SQLite 60,882→58,830 字符,均保留 59,000 上限。首读加导航在基线与当前头各 13,328 字节。 错误摘要在基线、前一版和当前头均拒绝。前一版的首读及子路径缺失在 File 和 SQLite 上复现,当前头两端均恢复。不同的 CLI 审核义务保留内联。 352 项聚焦 Python、69 项 TypeScript、控制面类型检查和 Ruff 通过。直接预合并检查 6 项、选中检查 19 项通过。本地严格合并检查未读到当前范围质量回执。 当前头仅验证源码 CLI。未测安装版 App 的实际模型输入、平台采纳或实时代价。作者报告的全量 TS 检查失利保持为独立合并记录,本轮未运行全量 TS 或查询远端 CI。

我的整体评价 / Verdict

批准当前提交,未发现阻断项。这次去重可在同一捕获重建完整义务,旧原生读法继续可用。字节差只发生在显式完整包,首读传输成本与基线相同。 只改 CLI 包体和读取路径,前端呈现未改变。

English verdict: APPROVE at 2c5dcf6. The full File/SQLite packets each shrink by 2,052 bytes. Native first reads, nested selections, root readback and default routing preserve the checked semantics. Local merge qualification remains separate.

@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 · Gemini · Google · self_reported

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

[P2] 顶层导入测试夹具模块导致 CLI 输出预算回归冒烟 cli-output-budget-regression-smoke 直接崩溃

tests/control_plane/test_cli_output_budget.py 在模块顶层新增了 from tests.control_plane.canonical_authority_fixture import isolate_sqlite_runtime(第 36 行)与 from tests.control_plane.codex_checkpoint_fixture import selected_context_values(第 44 行)。然而仓库的预算差分回归入口 examples/control_plane/cli-output-base-head-differential-smoke.py(由 examples/control_plane/cli-output-budget-regression-smoke.py 调用,同时属于 .github/workflows/python-tests.yml 与 agent-facing-cli-output-budget canary profile 的门禁检查)在构建对比环境时仅导出非 tests/ 源码并仅把 cli_output_fixture.py 预注入 sys.modules,不会复制上述两个夹具文件。在不变基线 02fd18df7fa119f21611646853b5d14d6448f15e 上运行 cli-output-budget-regression-smoke.py 正常通过(cli-output-budget-regression-smoke ok,退出码 0);在当前精确头 2c5dcf646061aae9dcc644963804b9bba63b0ea8 上运行则在导入阶段立即抛出 ModuleNotFoundError: No module named 'tests' 并失败退出(退出码 1)。最小修复是将第 36 行与第 44 行的两处导入移入 test_complete_turn_shares_vision_audit_with_exact_native_and_stateless_reads 函数体内(与同文件第 1188–1189 行、第 2030 行的延迟导入一致),然后重新运行 examples/control_plane/cli-output-budget-regression-smoke.py。相关代码

动机 / Motivation

在 36 条 Todo、12 次运行且存在未闭环 Vision 验收缺口的工作负载上运行 quota should-run --complete-turn 或 --codex-app 的 Agent、依赖 quota context-read 与原生上下文 hook 读取已捕获决策的调用方,以及执行 CLI 输出预算回归门禁的校验链路都会受到直接影响。改动前(基线 02fd18d),--complete-turn --context-delivery off 在 interaction_contract.cli_channel.vision_continuation_audit 中重复内联整份 CLI Vision 审核视图,固定短路径探针下 File 与 SQLite 输出分别达到 60,868 与 60,882 字符(超出 59,000 字符上限);而在更早的 PR 提交 9728962 中虽然替换成了引用存根,却因捕获读取端未做还原而导致原生首读丢字段、子路径 --select 失败。当前精确头 2c5dcf6 把相同工作负载分别压减 2,052 字符至 58,816(File)与 58,830(SQLite)字符,并在 File/SQLite 两侧的原生首读、子字段 --select、--list 与 verified_context_selection 中完整还原 CLI Vision 审核。实测运行时去重与捕获还原已在 File 和 SQLite 双后端闭环(Complete Turn 输出降至 58,816 / 58,830 字符,<= 59,000;原生首读、--select、--list 与 --select '' 均正确),但新增在 tests/control_plane/test_cli_output_budget.py 顶层的两处测试夹具导入破坏了 cli-output-budget-regression-smoke.py 门禁(抛出 ModuleNotFoundError: No module named 'tests'),因此当前仍不可合入。本 PR 不调整 59,000 字符硬上限,不改变非 Complete Turn 默认 quota_packet 的内联输出,也不修复基线既有的 content_digest_single_owner.test.ts 缺失消费者用例。

改动思路 / Approach

把 Complete Turn 去重保留在 turn_envelope_references.ts,并在 decision_capture.py 与 native_context_selection.py 中复用 cli_vision_audit_view 还原展示视图,能够把不可变签名捕获与按需读取清晰解耦,避免新增平行选择器或改动 progressive_context.ts。具体而言,写入端仅在 composeCompleteTurnDecision(turn_envelope.ts#L1000)显式传入 shareCliView = true:先将 cli_channel.vision_continuation_audit 与从根 $.vision_continuation_audit 派生出的 cliVisionAuditView(owner) 做精确结构比较,仅当完全等价且替换后字节更小时才写入类型化引用 {projection_ref: "$.vision_continuation_audit", projection_view: "cli_channel", required: true};若通道义务存在差异或更短则继续保留内联。读取端从 interaction_contract.py 抽离单一真源 cli_vision_audit_view,并在 decision_capture.py::context_vision_audit_view 与 native_context_selection.py::verified_context_selection 中针对 loopx_turn_envelope_v1 且带 projection_view: "cli_channel" 的捕获在 TS 地址规划、视图渲染和区段摘要校验前还原 CLI 视图,同时保证 --select '' 空指针继续返回未改动的原始签名捕获。当前 PR 边界覆盖 Complete Turn 写入端去重、Python 捕获读取端还原与双语协议/台账更新;仅需将 tests/control_plane/test_cli_output_budget.py 顶层的两处夹具导入移入测试函数体内以恢复预算回归门禁。

路径 / 场景 基线 02fd18df7fa1 前一审阅头 9728962da3 当前精确头 2c5dcf6460(File / SQLite)
--complete-turn --context-delivery off 字符数(固定路径) 60,868 / 60,882(超 59,000) 约 58.8k–59k 58,816 / 58,830(<= 59,000,-2,052)
原生/无状态首读与子路径 --select / --list 完整返回(内联) 丢字段 / context_selection_missing_pointer 完整还原并校验(File & SQLite 实测 PASS)
显式空指针 --select '' 返回原始签名捕获 返回原始签名捕获 返回原始含引用存根的签名捕获(PASS)
cli-output-budget-regression-smoke.py PASS(exit 0) 未受此顶层导入影响 FAIL(ModuleNotFoundError: No module named 'tests')

具体改动 / Changes

本次审阅针对精确头 2c5dcf646061aae9dcc644963804b9bba63b0ea8,对比 PR 基线 02fd18df7fa119f21611646853b5d14d6448f15e(当前 origin/main 位于 d38052695c,其间 7 个提交与本 PR 10 个文件无交集),总改动 10 个文件 +232/-33(5 个生产文件 +102/-33、3 个双语协议/台账文档 +35/-0、2 个测试文件 +95/-0)。相较于上一轮审阅头 9728962da3,作者已彻底修复原 progressive_context.ts 漏选与子路径 --select 报错问题。依据变动前已生效的协议规范 https://github.com/loopx-project/loopx/blob/02fd18df7fa119f21611646853b5d14d6448f15e/docs/reference/protocols/quota-cli-hot-path-compaction-v0.md(固定基线修订 02fd18df7fa119f21611646853b5d14d6448f15e)逐项核验:

  • same-workload-cli-budget-ceiling:implemented — turn_envelope.ts#L1000 与 turn_envelope_references.ts#L315-L398 使 36-Todo 12-run Complete Turn 响应在 File(58,816 字符)与 SQLite(58,830 字符)下均落入 59,000 上限。
  • complete-packet-and-default-off-parity:implemented — 根 $.vision_continuation_audit、默认 quota_packet(3,178 字符)、有差异的通道义务及 --select '' 签名原件均完整保留。
  • native-progressive-read-obligation-parity:implemented — decision_capture.py#L727-L753,L813-L875 与 native_context_selection.py#L145-L148 在 File 与 SQLite 的无状态和原生会话首读、--select、--list 及 verified_context_selection 中完整还原 required_before_closeout 与 9 字段 vision_gap_judge。
  • cli-budget-differential-smoke-parity:not_met — tests/control_plane/test_cli_output_budget.py#L36,L44 的顶层夹具导入导致 cli-output-budget-regression-smoke.py 在无 tests/ 包的差分隔离环境中导入失败,需将两处导入移入测试函数体内。

另外,本 PR 同步增补 docs/reference/protocols/quota-cli-hot-path-compaction-v0.md(第 113–130 行)与双语 RFC 台账 2026-11-04-selected-context-source-read{.md,.zh-CN.md},清晰界定了 projection_view: "cli_channel" 的精确相等替换与同捕获还原边界,是对既有共享引用规范的正当扩展。

关键代码讲解

  1. cliVisionAuditView 与 referenceVisionContinuation:在 turn_envelope.ts#L1000 传入 shareCliView = true 时,从根 vision_continuation_audit 提取预期 CLI 字段集并与 cli_channel.vision_continuation_audit 做规范哈希比对,仅在完全等价且缩短字节时写入 CLI_VISION_AUDIT_REFERENCE。
  2. requireVisionAuditReferences:强化校验逻辑,拒绝在根 vision_continuation_audit 上出现 projection_view,并确保 projection_view: "cli_channel" 仅出现在 interaction_contract.cli_channel 路径且满足完整内联根 owner 与字段全等要求。
  3. cli_vision_audit_view:将原本内联在 _attach_interaction_vision_continuation_audit 中的 CLI 视图构造提取为单一 Python 函数,供生产组装与捕获还原共用。
  4. context_vision_audit_view:仅针对 loopx_turn_envelope_v1 且 cli_channel.vision_continuation_audit.projection_view == "cli_channel" 的捕获,在校验存根精确值(含 audit["required"] is True 防 1 == True 混淆)及完整内联根 owner 后还原 CLI 视图;_context_selection_bytes(第 734 行)保留 path 为空时直接输出原 payload,从而确保 --select '' 返回原签名对象。
  5. verified_context_selection:在计算原生已读区段摘要 context_read_sections 时同样传入 context_vision_audit_view(source),使其与 context_selection_view 渲染的页面字节和地址完全一致。

对主干的风险 / Risks

  • 唯一阻塞回归与触发路径:见顶部 [P2],tests/control_plane/test_cli_output_budget.py#L36,L44 的顶层夹具导入会直接阻断 cli-output-budget-regression-smoke.py(和 Python CI 工作流)。修复后请重跑 uv run --extra test python examples/control_plane/cli-output-budget-regression-smoke.py 验证通过。
  • 默认关闭隔离与反事实校验:非 Complete Turn 的普通 quota should-run(cli_projection.py 调用 reference_context 默认 shareCliView = false)在 File 与 SQLite 下基线与精确头均稳定输出 3,178 字符;context_vision_audit_view 对非 loopx_turn_envelope_v1 保持原样;负向反事实验证缺失根 owner、链式 projection_ref、required: 1、错误 projection_ref 均严格抛出 ValueError / EffectRuntimeRequestError;--select /interaction_contract/cli_channel/vision_continuation_audit/projection_ref 准确返回 context_selection_missing_pointer,而 --select '' 仍返回原签名存根。
  • 生产调用链与非阻塞兼容观察:composeCompleteTurnDecision、context_vision_audit_view、verified_context_selection 与 cli_vision_audit_view 均有现行生产调用链覆盖(无孤立代码)。非阻塞细微边界:TS cliVisionAuditView 使用 pickOwn 会省略缺失键,而 Python cli_vision_audit_view 会为缺失键补 []/None;生产链路中 build_vision_continuation_audit 恒定产出完整键集不受影响,仅极端手工裁剪缺键的 TS 输入再交由 Python 还原时会补出默认空值,可作为后续清理。
  • 本地验证实测:
    • tsc --project tsconfig.control-plane.json --noEmit:PASS
    • TypeScript 关联测试 8 个文件(含 turn_envelope.test.ts、context_selection.test.ts、progressive_context.test.ts 等):157/157 PASS
    • TypeScript 全量测试(npm run test:control-plane):6,732 pass, 1 fail, 91 skip;唯一失败 tests/control_plane_ts/content_digest_single_owner.test.ts(CANONICAL_CONSUMERS 缺少 control_plane/quota/execution_loss_closeout_record.ts)已在不变基线 02fd18df7fa1 上复现同等失败与签名,判定为 pre_existing_unrelated。
    • ruff check(4 个改动 .py 文件):PASS;mypy --follow-imports=silent(3 个改动 loopx/ .py 文件):PASS;scripts/check_rfc_bilingual.py --base origin/main --head HEAD:PASS;loopx check --scan-path(全部 10 个改动文件):PASS(0 error / 0 warning)。
    • Python pytest 定向 10 个文件(test_cli_output_budget.py、test_context_capture_selection.py、test_context_read_reference.py、test_saved_context_project.py、test_progressive_native_context.py、test_codex_context_capture.py、test_complete_host_request.py、test_quota_cli_projection.py、test_quota_vision_audit_references.py、test_turn_envelope.py):518 passed, 60 skipped(跳过项为 Windows/PowerShell7 与需外部 LOOPX_NATIVE_CHECKPOINT_BIN 的用例);test_vision_budget_cli.py 与 test_cli_output_differential.py:225 passed, 1 skipped。
    • loopx canary premerge --from-git-diff --git-diff-base origin/main:6/6 direct checks、10/10 catalog canaries、8/8 risk-profile smokes、1/1 public-boundary scan(选中 19/19 PASS);Goal 策略 change_quality_qualification 对当前 d38052695c..2c5dcf6460 报 receipt_missing(属独立合并门禁,且 PR 描述已注明前序 cqr 保留了 TS 预存失败)。
    • examples/control_plane/cli-output-budget-regression-smoke.py:基线 02fd18df7fa1 PASS,精确头 2c5dcf6460 FAIL(ModuleNotFoundError: No module named 'tests',pr_regression)。
    • File/SQLite 配对运行与原生会话实测(固定路由 --cli-bin /fixture/bin/loopx 配对实测):--complete-turn --context-delivery off(60,868→58,816 / 60,882→58,830)、无状态及原生 --codex-context-root Turn 1/Turn 2 首读/--select/--list/verified_context_selection 及负向探测全部 PASS。

语义与 CI 对齐

本次在 docs/reference/protocols/quota-cli-hot-path-compaction-v0.md 的共享 projection_ref 词汇基础上按 extend_vocabulary 扩展了 projection_view: "cli_channel",并配有严格全等与 fail-closed 约束,未引入域专用字符串规则。CI 状态按 Goal 策略不作阻塞依据(wait_for_ci: false)。

我的整体评价 / Verdict

problem_context.outcome_impact 中 long_horizon 判定为 preserved、user_experience 判定为 improved(视觉审阅结论:本 PR 仅涉及 TypeScript/Python CLI 控制面、文档与测试,未改动任何前端 UI 渲染组件,故 visual_review 为 not_applicable;未验证范围:none)。observable_semantics 判定为 intentional_change_validated,code_volume 为 necessary(兼容策略 retain),change_proportionality 为 proportionate(架构评估 retain),default_off_isolation 为 isolated,authority_semantics 为 not_applicable,共享词汇采用 extend_vocabulary(扩展 quota-cli-hot-path-compaction-v0.md 的 projection_view: "cli_channel")。运行时去重与 File/SQLite 捕获还原逻辑扎实、干净且已完整闭环,但仍需注意 59,000 上限在长工作树路径下仅余约 4–18 字符余量(相对作者在 PR 正文报告的 58,982 / 58,996 实测),以及 PR 尚落后 origin/main 7 个无文件冲突提交与缺少最新 base 的 change-quality 回执。此外,本轮在已有同头通过审阅之后仍补充独立阻断结论,是因为前置审阅未运行 examples/control_plane/cli-output-budget-regression-smoke.py;待作者将 tests/control_plane/test_cli_output_budget.py 第 36、44 行的两处顶层测试夹具导入移入测试函数体内,并确认 examples/control_plane/cli-output-budget-regression-smoke.py 在隔离环境下通过后,即可重新提交复审。

English verdict: REQUEST_CHANGES. At 2c5dcf646061aae9dcc644963804b9bba63b0ea8, Complete Turn Vision sharing reduces the 36-Todo fixture to 58,816 (File) and 58,830 (SQLite) chars (<=59,000) and restores all CLI obligations across stateless and native reads, but top-level test-fixture imports in tests/control_plane/test_cli_output_budget.py#L36,L44 break examples/control_plane/cli-output-budget-regression-smoke.py (ModuleNotFoundError: No module named 'tests').

@mergify

mergify Bot commented Nov 22, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @loopx-agent.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 22, 2026
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.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 · exact head 411727c082d68ebba312ddd6714efdf05d4d314f\n\nApproval conclusion (author-owned PR; GitHub blocks formal self-approval). The integrated head preserves CLI vision-audit sharing and main's opening-context instruction projection. The regression-causing test fixture imports are now scoped inside the owning test, restoring the isolated differential environment.\n\nValidation: the complete-turn vision audit cases passed; passed; passed.

@loopx-agent
loopx-agent merged commit 2daa3a4 into main Nov 22, 2026
14 of 16 checks passed
@loopx-agent
loopx-agent deleted the codex/repair-complete-quota-cli-budget-20261119 branch November 22, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Mergify: the pull request has merge conflicts with its base branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant