Skip to content

Validate quota audit references before a staged replan - #8113

Open
loopx-agent wants to merge 1 commit into
mainfrom
codex/vision-audit-readback
Open

loopx-agent wants to merge 1 commit into
mainfrom
codex/vision-audit-readback

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

A historical quota decision can carry one full vision audit and refer to it from the frontier or the agent channel. On main, a staged replan accepted a channel reference saying the goal was done even though the original judge said to continue. The capture had the correct digest and an otherwise usable replan context.

The staged reader now checks these references against the literal audit in the same capture. Matching references preserve the original decision, stop conditions and negative evidence. Conflicting references, unresolved owners and chains are rejected. The display writer uses the same rule, keeps short audits inline, and compares the original numeric values before sharing. It performs this work in the existing display RPC. Unrelated context source rows retain their original positions and contents in the capture, but their bodies stay outside this request.

A regression test first completes a valid staged review, then changes the referenced stop decision, recomputes the source hash and verifies rejection. Main accepted the changed decision. Real File and SQLite CLI checks cover capture, display, recovery and absence of quota spending during the read. All 201 tests in the five related Python suites passed. The TypeScript suite passed 44 checks and the strict typecheck passed. Quick premerge passed with one inherited maintainability advisory in an untouched function.

In a matched replay of two benchmark steps and a separate local capture, the standalone display RPC sent and returned 126,834 B across three calls, compared with 438,084 B across three calls on main. All three tool outputs matched byte for byte. These are internal serialized bytes for display, measured separately from model input and task outcomes.

Independent extraction from #7430. It can be reviewed against main. A local integration with #8100, #8106 and #8110 passed all 81 tests covering these audit, acceptance and staged-reader paths.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@mergify

mergify Bot commented Nov 5, 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 5, 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.1-sol · OpenAI · runtime_reported · reasoning_effort=max

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

动机 / Motivation

通过 quota 命令读取重规划材料并判断是否继续工作的 Agent。此前保存的引用可携带与根审计相反的 done/decision 而被读者接受;当前 head 在进入重规划前拒绝冲突,正确引用仍能读取。实际 CLI 的 File 和 SQLite 后端拒绝五类哈希正确的坏引用,修正后可恢复有效读取,状态与消费记录不变。本 PR 不改变准入、预算或结算权限,也不证明模型已理解或采用投影材料。

改动思路 / Approach

审计是解释当前目标是否需要继续的完整材料。以已有 inline 根为唯一完整 owner,仅将完全一致的副本变成可回溯引用;不同 channel 仍独立保留。读取阶段验证引用而不是相信 hash 已证明语义,避免矛盾 done 信息绕过 guard。Python 保留 IO,TS 负责投影规则,既有 staged reader 继续负责读阶段。

保持既有 TS 决策 owner 与 Python IO 边界;直接验证正确性,不增加配置、持久状态或新的执行权限。本 PR 只收敛审计引用投影与读取校验;Python 类型收窄仍须修复。本改动不声称 default-off;没有新配置、激活或额外人工确认。实际比较沿用原入口与授权,失败由原调用者修正后重试。说明采用源码链接和正文;没有使用未经验证的渲染图代替执行证据。

具体改动 / Changes

Python 删除重复的审计共享规则,使用既有 TS context owner 完成一次粗粒度投影 RPC,并保留原 source 编号及未识别 source 在本地。TS 根据完整结构和原数值身份决定是否共享:相同的大审计改为根引用,不同 channel、短审计或历史 inline 保持原样。replanView 先确认完整根 owner 与每个引用事实一致,再进入已有 staged reader。测试覆盖真实 guard/capture、数值边界、不同审计、缺 interaction 与无关 source;既有 diagnostic edit lineage 继续承担原索引应用。完整 judge、历史、研究顺序、写回、done/continue 条件仍在根上,引用不是完成证明。

关键代码讲解

规范依据:docs/development/testing-and-quality.md,不可变版本 12803354ab13a003de8620ab496250617224ff37(先读规范,再读实现)。以下是本次评审对原文条款的定位锚点,不是新增协议编号:

  • audit-canonical-owner:implemented,Retain one complete inline audit with judge, history and continuation obligations;由上述 owner 和真实调用反例覆盖。
  • audit-copy-identity:implemented,Only identical copies can be replaced; different channels remain inline;由上述 owner 和真实调用反例覆盖。
  • audit-staged-continuation:implemented,Staged reader must not accept conflicting or unresolved audit references;由上述 owner 和真实调用反例覆盖。
  • audit-complete-detail:implemented,Short or historical inline data and unrelated context sources retain their original meaning;由上述 owner 和真实调用反例覆盖。

另核对 quota-cli-hot-path-compaction、required-work-context 与 goal-vision-replan-contract 的完整审计及继续条件;这些功能条款已验证,静态类型交付缺陷单独阻塞。

对主干的风险 / Risks

[P2] 新增可空字典变量缺少类型收窄,导致原配置 mypy 回归。 在 cli_projection.py 的 552、553 行,contract 与 agent 的类型仍为 Any | None,却直接用于字典解包;682 行又将同样可空的 vision_audit 传给要求 dict 的函数。运行 uv run --extra test python -m mypy,当前 head 报三错;不可变 base 使用同一原配置通过 17 roots。请在既有 adapter 内显式收窄这三个值,保留原检查与配置并重跑,不要用 ignore 或排除文件掩盖问题。

引用功能的独立反例通过:对合法历史重规划输入分别注入 done 冲突、decision 冲突、错误引用、缺根与链式根,并重新计算正确 source hash,原基线均接受,当前 head 均拒绝;随后正确读取可恢复,File/SQLite 的 Goal 状态与索引字节不变,spend 为零。TS 三模块 69 项通过。五个 Python 相关套件是 145 PASS / 10 FAIL,不能称全绿;这十项原有 staged 测试在 base/head 用相同节点重现相同 navigation-envelope 诊断,完整 35004 字节归一化结果 SHA 为 531daa186a99538b846643b01cb77df906859e1f9dea19d4deca568de8c2b12f,保留为已有失败。标准 premerge 的 6 direct + 13 selected 通过,maintainability advisory 保留,但不能覆盖上面的 required mypy 回归,CQR 为 fail。

当前审查基于原 PR base 12803354ab13a003de8620ab496250617224ff37 和 head fbef1f6042cd13f665c23579e7618003c254b0a9,另检查了相关最新 main 的变化。没有抓取、轮询或等待 GitHub CI。独立环境是 source checkout、Python 3.14.8 与 Node 24.21.0;真实后端仍使用合成 fixture,不声明安装包、Windows、Lark 或实际模型采用通过。评审探针准备期间的 fixture 假设错误被修正后重跑;不计为 PR 缺陷,也不据此抹去套件失败。

我的整体评价 / Verdict

长期工作能力 preserved:完整审计与恢复读取保留,矛盾停止信息被拒绝;用户体验 not_yet_proven:局部 CLI 功能改善已验证,但原类型必检失败,完整交付尚未成立。最小修复是 adapter 类型收窄后通过原配置 mypy,并保持现有正负例。已检查 CLI 投影和读者;本次改动 JSON 引用及校验,不改变渲染页面。已安装 App、浏览器与模型理解未执行;本次没有受影响的视觉变更。

删除 Python 重复决策、复用 TS owner 的边界合理,规模与可复现的引用错误相称;当前仍须修复三处类型错误。请求修改基于这个新增回归,不要求本 PR 承担已有 navigation 测试故障。语义词汇复用原 action/audit/reference;没有新 actor 生命周期或权限,semantic diff advisory 通过。上下文存在与回读不证明模型理解、Host 采用、长期净收益或完整成本;这些维度仍未测试。

English verdict: REQUEST_CHANGES — exact head fbef1f6042cd13f665c23579e7618003c254b0a9; fix the three introduced mypy errors, then rerun the unchanged configured check and reference regressions.

(task_title and row.get("source") == "selected_todo")
or (explore_guidance and row.get("kind") == "explore_turn_context")
) else None for row in context["sources"]]
source["interaction_contract"] = {**contract, "agent_channel": {

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] 保留原配置 mypy 的类型收窄:这里 contract 与 agent 仍可能是 None,新增字典解包在 552、553 行报 dict-item;682 行还将可空 vision_audit 传给要求 dict 的函数。原配置 uv run --extra test python -m mypy 在不可变 base 通过 17 roots,而本 head 新增三错。请在既有 adapter 显式收窄这几个值后再解包/调用,并保留原检查重跑。

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

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