Skip to content

refactor(quota): delegate stateless read selection to TypeScript owner - #9142

Merged
loopx-agent merged 2 commits into
mainfrom
codex/mechanism-context-selection-20261120
Nov 21, 2026
Merged

loopx-agent merged 2 commits into
mainfrom
codex/mechanism-context-selection-20261120

Conversation

@cocolord

@cocolord cocolord commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Stateless capture publication duplicated the TypeScript Progressive owner's normal-work classification in Python. Route that initial-navigation decision through the existing context_select operation, retaining the capture adapter's publication, byte budgets and fallback behavior.

The optional normal_work_initial_read boolean is invocation-only. Omitted or false requests retain generic selection and validation order; non-normal sources retain root discovery and initial pointers. Existing EffectiveAction and channel facts remain authoritative. This adds no public CLI setting, persisted vocabulary, provider or admission owner.

File/SQLite regression coverage captures unprepared and ready sources, then verifies that later claims cannot alter historical preparation, settlement identity or digest rejection. Existing wide-scope and note-reuse test callers now pass their original captured lease proof to manual writeback; pagination, recovery and once-only settlement assertions remain intact. The same repaired harness also passes against unchanged base production code.

Validation:

  • 75 TypeScript tests and control-plane typecheck passed.
  • File/SQLite frozen-input comparisons passed for complete policy facts, actual advertised first-read pagination, feature-off parity and refusal behavior.
  • Complete reader regression: 251 passed, 14 skipped because explicit native Codex isolation was not configured. The same repaired reader controls pass against base production code (26 passed).
  • Standard premerge passed on 5878d78441f5fd03ea1a2232c10114bc9caa97b1: exact-head bilingual/compile/diff and module checks, 10 catalog checks, 8 runner risk checks and public-boundary scan; zero failures. Goal change-quality policy is disabled. GitHub CI and maintainer review remain separate gates.

Remote CI holds: the documentation build rejects the existing docs/reference/protocols/turn-envelope-v0.md link to benchmark/runtime/RUNTIME.md, whose target is outside the built documentation set; that link is identical in the verified base. The live PostgreSQL conformance row reports a TAP failure, while its retained report omits the failing inner test. The same base passed PostgreSQL CI. One retry of the failed PostgreSQL job is requested on this unchanged head; its result is pending. Neither remote check is counted as passed.

The bilingual mechanism RFC records this as a source ownership checkpoint. Full C1/C4/C9 cutover, installed/native adoption and independently measured method/outcome benefit remain open. This proposal does not claim complete RFC acceptance or merge authorization.

@cocolord cocolord left a comment

Copy link
Copy Markdown
Member 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; provider=TRAE; declaration_source=self_reported

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

结论:APPROVE。没有发现本次改动引入的阻断缺陷。审查范围为 eb552a8bb0532de117513ee5277a92e74e746309 → 5878d78441f5fd03ea1a2232c10114bc9caa97b1 的完整 8 文件 diff;合入门与代码结论分开。

动机 / Motivation

维护者修改无会话工作读回规则时,会同时遇到 Python 发布适配器和 TypeScript 内容选择器。
以前同一组正常工作条件在两种语言分别维护;现在既有 TypeScript owner 统一判断,Python 继续发布同一份捕获内容。
两个解释点会让后续规则变化需要同步维护,并增加出现不同读回分支时的定位成本。直接不改动保留这个问题,在 Python 再抽一个函数也仍有第二个语义 owner。
真实 CLI 的 File/SQLite 捕获、实际分页、关闭和摘要拒绝行为保持一致,重复分类器已经退役。
本 PR 不完成整个 C1/C4/C9 切换,不证明模型采用或方法收益,也不改变执行权限、公开 CLI 设置或持久状态。
完整调用切换、原生与安装版采用、组合执行和成果收益仍待各自验收。

改动思路 / Approach

保留既有 typed owner 和发布适配器职责,去掉重复判断;调用选项只控制自动初始导航,原始捕获继续拥有事实。
当前 PR 边界是一个真实无会话调用的分类所有权迁移,以及保持原 lease proof 的相关测试修复。
quota context-project 先验证原始捕获摘要与身份,再进入 native_context_capture_view。只有无会话 IO 条件满足时,适配器向既有 context_select 请求 normal-work-only 的自动导航;真实判断由 TypeScript 完成。非正常来源保留 discovery,状态化初始计划及已附加页面继续走原分支。Python 的发布、字节预算、可选 runtime 故障 fallback 没有搬到决策 owner。

省略或 false 的调用必须维持通用选择,不能让本次适配器的限定覆盖其他 reader。历史捕获的准备和结算事实继续来自原文件,后来出现的新 lease 不能成为旧捕获的权限。RPC 与适配器同一 source checkout 部署,新增字段不需要另一份持久配置或独立 provider。

具体改动 / Changes

规格依据:docs/architecture/rfcs/mechanism-convergence-and-learning-loop-v0.md,接受前 revision eb552a8bb0532de117513ee5277a92e74e746309。§3 在本切片映射为 implemented:保持原身份、claim/lease、Stop、授权输入与失败恢复;迁移真实 caller 并退役替换后的正常判断。完整父 RFC 的执行切换与成果收益仍 deferred,沿原 C1/C4/C9 工作和相关 PR 继续,未将该 checkpoint 当作总验收。

关键代码讲解

  • native_context_capture_view 删除 Python 的 stateless_ready 语义条件,仅保留 IO 分支并发送 normal_work_initial_read=True。拿到普通 discovery 时保留 root index/initial pointers,捕获摘要检查仍在选择前。
  • normalWorkReadContext 复用 EffectiveAction.NORMAL_RUN 和两个 strict-true delivery 条件;原 readySettlementIdentity 仍检查准备状态和完整身份,initialContextReadGroups 仍保留 selectingBeforeWork 例外。
  • capturedDecisionSelection 在既有 RPC 验证可选 boolean;只有限定的非正常来源关闭自动 initial plan。省略/false 不提前解析 context,保留重叠非法输入的原错误优先级。
  • test_stateless_saved_work_keeps_the_captured_preparation_and_readback 使用真实 File/SQLite CLI,先捕获 unprepared,再 claim 并捕获 ready,检查旧来源不会借用新 lease、拒绝错误摘要、保留源文件/状态/回执且没有 debit。其他测试改动把原捕获 proof 带回原手动 writeback,保留分页、恢复和一次结算断言。

两个 RFC 文件只新增描述性 source checkpoint,明确完整 C1/C4/C9、原生/安装版采用及方法收益开放。运行代码仅 +25/-19 行,没有新模块、公开 CLI 参数、持久 vocabulary、安装路径或 capability activation。现有 generic reader 是保留省略/false 分支的实际消费者;不是用历史回执为另一个 request decoder 辩护。

对主干的风险 / Risks

最强反例是:测试通过重建原 source 得到正确 policy,但实际 first-read 页面已经漏掉权限、Stop 或准备事实。因此我实际执行 advertised first_read_command 并读完分页,在 File/SQLite × unprepared/ready × auto/off/digest-refusal 的 12 组相同输入上比较 base/head。实际选中内容或完整拒绝行为一致。仅规范化已知 checkout 路径前缀,保留指针、顺序、值和诊断。

PASS:67 个 TurnEnvelope TypeScript 测试、control-plane typecheck、2 个真实历史读回用例、精确双语 RFC 检查。PASS:2 个故意遗漏 Goal 边界指针的变异经过真实 RPC 及公共读回后被检测,控制输出保留该边界。复用的同 head 完整 reader 回归为 251 PASS / 14 SKIP;14 个显式原生隔离环境用例仍未验证,未把它们计为通过。既有 standard premerge 的 6 个直接和 19 个选中检查通过;复用前已核对提交、调用、依赖和 touched-owner 的 main 变化,没有失效项。

FAIL(独立 CI hold):stage2c mutants 在 public_refresh_writes_owned_paragraph 变异定位时报 ValueError: mutation locator drift; review source and oracle。相同选定命令在不可变 base 与 head 重现同一位置和签名,变异脚本与 state_refresh.py 都未变更,不能归因于本次读回分类迁移。文档站 FAIL 的链接在 base/head 均存在,本文没有新增该链接;没有声称做过完整基线站点构建。UNVERIFIED:PostgreSQL 首次 TAP 失败缺少内部失败用例,重跑尚未取得最终结果;保留未知原因。以上诊断不会替代当前 changed-invariant 证据,也不意味着远端 CI 或 merge readiness 通过。

语义与 CI 对齐

新 helper 重用既有 enum;调用 boolean 属于内部瞬时意图,没有新的闭集 vocabulary 或 actor/authority 语义。runtime 提示与原捕获的权限、准备和结算内容在实际对照中一致,描述性 RFC checkpoint 没有改变强制义务。默认关闭及 generic omitted/false 输入不引入配置、同步状态或额外执行;重复 publisher/decoder 没有留下第二个正常判断。

我的整体评价 / Verdict

这是 justified_increment:一个真实 caller 完成了正常读回分类所有权迁移,边界可独立测试和回滚。long_horizon 为 preserved,历史身份、后续 claim 和一次结算仍保持;维护收益是合理方向,尚未证明完整预算下的成果改善。user_experience 为 preserved,既有读回/恢复无需新增设置或确认。
检查 quota_capture.py、quota_context_reader.py 及 apps/packages 的 diff 后,没有渲染界面改动;CLI 实际内容已做基线/head 对照。
未验证范围:原生模型采用与安装版完整旅程未验证,不属于该源码切片的通过结论。既有 PR8942 的 native/history 工作及 PR9131 的另一处 proof 调用仍是开放相关边界;没有把它们的测试或状态继承为该 PR 的总验收。保留已有 typed owner 和局部适配器比另建控制器或公开开关更合适,没有需要在本次修改的实现缺陷。

APPROVE 是代码审查结论。该 PR 的 CI、behind 状态、exact-head merge readiness 和 maintainer 合入授权仍是独立门;本次不执行合入。

English verdict: APPROVE — reviewed head 5878d78441f5fd03ea1a2232c10114bc9caa97b1. No introduced blocking finding; real File/SQLite readback, disabled/refusal parity and public-path mutation sensitivity passed. Native adoption and unresolved remote CI remain separate qualification and merge holds.

@mergify

mergify Bot commented Nov 21, 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, @cocolord.

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 21, 2026
loopx-agent
loopx-agent previously approved these changes Nov 21, 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.2-sol; OpenAI; runtime_reported; reasoning_effort=xhigh

动机 / Motivation

使用无会话 CLI 的 Agent 或宿主需要从已保存的准入决定读回当前任务、准备状态和恢复命令。原先 Python 与 TypeScript 各自判断正常工作的首读模式,后续改规则时容易让同一份 capture 在不同入口产生不同导航。现在由既有 TypeScript 选择器同时决定首读和通用发现,Python 仍负责原文件验证、落盘、字节预算与回退。File 和 SQLite 的四组同输入都保留原决定与首读内容。范围是本次源码所有权收敛,完整 C1/C4/C9 退役、安装版与真实 Host 采用及成果成本收益仍需原计划验证。

目标依据是改动前的 Required work context,版本 eb552a8bb0532de117513ee5277a92e74e746309。按此前已经接受的只读恢复与义务保留语义审查这个切片。改动前的机制 RFC §5.5、§8 提供收敛方向,现提案补入的 checkpoint 是结果记录。已有的工作区演示经验提醒我检查读回后的可执行下一步。此切片消费的是 CLI 导航,当前无需改桌面布局。

改动思路 / Approach

选择器复用当前动作和 Agent 通道事实,消除 Python 对正常工作状态的第二次解释。当前边界是迁移无会话首读选择,同时保留已有文件、恢复和分页协议。normal_work_initial_read 只表达调用方是否请求针对正常工作的首读计划。TypeScript 检查已捕获的状态,非正常或缺字段时回到原根索引。Python 将验证后的地址渲染成可回读命令,保留不可用时的原 capture。直接删除首读优化会让普通工作多一次手工选择,把整个 capture 流程移入 TS 则会改动文件与字节运输。保留现有 context_select 是更小的切片。

具体改动 / Changes

整提案相对 eb552a8bb0532de117513ee5277a92e74e746309 共 8 文件、+167/-25。三个生产文件 +25/-19,三个测试文件 +121/-6,双语 RFC +21。既有宽写范围及 Todo note 复用测试把原捕获的 lease proof 交回手工写回,保留原分页和结算断言。

规格 当前验证
CTX-IMMUTABLE File 与 SQLite 在准备前及准备后各冻结一份决策。之后对同一份原始字节分别调用基线和本头 context-project,原状态、摘要、准备证明和结算身份相同。
CTX-READ 按两版实际发出的 first_read_command 读至 EOF,对照完整选中值及同一 capture 的显式选读。四组首读逐项相同。
CTX-OFF 显式关闭时,两版结果只在所用 CLI 可执行文件路径上不同。无会话适配器对照也验证了关闭时无需调用新增选择分支。
CTX-REFUSE 错误摘要两版都拒绝。请求缺失字段、处于等待或未获准交付时保留通用发现,缺省或 false 继续用通用选择验证。

native_context_capture_view 只判断是否走无会话导航运输。 capturedDecisionSelection 验证可选布尔值,再由 normalWorkReadContext 复用原状态判断。capturedContextSelection 负责解析选择地址和验证顺序,文件适配器按原文读取并构造命令。就绪、未准备、未知形状与启动失败对照支持单次导航选择和既有回退。整个接缝没有新增持久字段、提供者或执行权限。

对主干的风险 / Risks

没有发现阻塞性缺陷。最相关的反例是用当前 lease 替换历史 capture 中未准备的状态,或者在拒绝坏摘要前发布新导航。两版对同一历史文件的真实调用保留原准备事实、原结算身份,且未改变源状态、注册表、准入回执和扣额计数。四组关掉功能的结果仅需规范化各自调用所用的 CLI 路径。打开功能时另有各次临时 reader 文件路径不同,实际执行了这些 reader 并逐项比较内容。注入选择器启动失败的本地探针保留原 recovery 路径,关闭时未调用选择器。它证明适配器故障处理,未模拟网络或真实 Host。

双语 RFC、quick premerge 的三个 canary 与公开边界扫描、67 项 TS、TypeScript typecheck 及 Ruff 均通过。两组 Python 首读与保存上下文回归共 251 项通过、14 项跳过。源代码验证覆盖本次涉及的 CLI 和 File/SQLite;作者描述中的 PostgreSQL 和文档构建 CI 仅作为诊断,未查询远端 CI,也未独立归因。

我的整体评价 / Verdict

APPROVE,绑定 5878d78441f5fd03ea1a2232c10114bc9caa97b1。保留既有选择器和 IO 边界,减少正常工作导航的规则重复,长程恢复语义和用户的 CLI 操作步骤保持。改动路径为 quota CLI 及原生选读的控制信息,没有 rendered page 变更。未验证范围为安装版与真实 Codex App 运行,以及实际 Agent 理解和完整成本。整体迁移仍由原计划验收。

English verdict: APPROVE at 5878d78. Stateless navigation uses the existing TypeScript selector while preserving frozen-capture policy, disabled output, digest refusal and fallback in paired File and SQLite CLI checks.

@loopx-agent
loopx-agent merged commit b396104 into main Nov 21, 2026
9 of 12 checks passed
@loopx-agent
loopx-agent deleted the codex/mechanism-context-selection-20261120 branch November 21, 2026 07:54
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.

2 participants