Repository navigation
fix(interaction): share closed-contract consistency checks - #6260
huangruiteng merged 3 commits into
Conversation
Signed-off-by: song <liusongstep@gmail.com>
Signed-off-by: song <liusongstep@gmail.com>
Signed-off-by: song <liusongstep@gmail.com>
songoow
left a comment
There was a problem hiding this comment.
Reviewer: model_agent; model=GPT-6 family (Codex); provider=OpenAI; self_reported (runtime observation unavailable).
动机
用户或 Agent 根据 quota 合同继续工作时,需要可靠地区分已结算状态与仍可执行的状态。此前同一份已结算合同可以被调度器判为需要修复,却被类型化解释器接受;扣费标志为 true 的矛盾合同还可以进入新建 TurnEnvelope,与其中的不扣费说明并存。本次让四个消费者共同拒绝十二组矛盾输入,正常工作与合法已结算合同的完整观察输出保持一致。这只校验合同内部一致性,不验证 Goal 身份、租约或外部权限,也不授予执行或扣费能力。rejected/deferred 选择准入和 #4447 的全量来源证据仍属后续工作,本 PR 不关闭这些范围。这些是构造矛盾输入后得到的真实 API 观察,不是已发生生产越权执行的声明。
改动思路
将既有执行一致性规则集中在 TypeScript interaction-contract owner,Python 仅提供规范化事实并保留结构诊断和 cadence 选择。本批删除 Python 中的重复语义判断,补齐关闭模式扣费拒绝,保留合法通知与原有调用路径;没有新增状态存储或结果缓存。Effect 解释器和 scoped-override 直接复用同一个检查;TurnEnvelope 构造经该解释器进入,因此在形成新动作摘要前拒绝矛盾状态。调度器经已有 Effect 传输调用规则,保留原来的 consistency-repair 反馈。未知通知文本不参与执行许可判断;关闭合同中原有的结束、不扣费指引继续保留。
具体改动
精确 head acbd371a9c7f5fb919762f0344e3188f6df78672,基线 df826263926651ab9c50acee182ef96e2a60ff4b。规格依据 docs/reference/protocols/loopx-turn-v0.md,spec_revision df826263926651ab9c50acee182ef96e2a60ff4b:In-flight Turn settlement 明确已结算 Turn 不再执行或重复扣额;Settlement identity decoding 的身份和提交凭证职责仍由原有 owner 承担,超出本次一致性检查范围。
关键代码讲解
interactionConsistencyIssues统一 delivery/attempt、quiet-noop、关闭模式动作与扣费之间的约束,沿用原有诊断码并增加 settled-spend 诊断。其他模式不被当成关闭模式。decodeInteractionContract保留原有严格结构读取,在生成类型化结果前应用公共检查。两项扣费标志缺失时保留历史 false 语义,显式值必须是布尔值;非阻塞通知仍可存在。projectInteractionConsistencyValidation通过既有 runtime handler 只读传输规范化事实和诊断。它不读写 Goal 或 lease,也不能给声明的 mode 赋予来源真实性。build_scheduler_arbitration删除重复 semantic if 分支,合并 TypeScript 返回的诊断;原有结构错误、诊断顺序、cadence 分类及修复提示保留。
In-flight Turn settlement 在受影响的合同消费边界已实现;Settlement identity decoding 保持原有实现且本次不改其契约,不能从本检查通过推导身份或权限通过。代码、回归和英中文档组成可单独回退的切片。
对主干的风险
合法 packet、独立 capability intent、workspace repair、通知与既有历史 packet 读回均在回归范围内。新的拒绝范围包括关闭模式中开放动作/扣费的矛盾,以及显式非布尔扣费字段;旧字段缺失仍兼容。Python 独立使用调度仲裁时现在依赖既有 Effect runtime 的语义检查,服务不可用会失败关闭,不能悄悄换用另一套规则。该依赖和行为收紧已在文档披露。
语义与 CI 对齐
同一脚本、同一公开合成输入在基线与 head 运行,覆盖调度器、解释器、scoped override 和 TurnEnvelope。基线独立 oracle 失败,head 通过;两条合法完整输出一致,十二条矛盾输入均被修复/拒绝。冻结历史 packet 的读取与实际 quota/CLI 路径另有测试,不将这些证据扩张成全部历史兼容或真实模型资格。
本地 165 项 Python、34 项 TypeScript、typecheck、Ruff 与完整 semantic drift 通过。相同补丁 premerge 的 10 项 catalog、8 项 risk smoke、公开边界及 diff/compile 检查通过;main rebase 后已重跑相关验证,最后提交只增加非阻塞通知回归和文档细化。当前远端为 1 success / 6 queued,暂无已报告失败,保留 CI 合并门禁。
运行成本经过单独核对:在生产已有 request scope 下,30 个 warm 样本的普通 quota 构造中位数为 15.4→17.7 ms,已结算为 18.9→17.6 ms。Python 增加一次只读调用,TS 消费者直接调用纯规则。先前未进入新增校验分支的裸构造差异不能归因于本改动;没有因此引入缓存、跳过 freshness 或放宽预算。上述不是完整 CLI、冷启动或线上 SLO 测量。
我的整体评价
Approval conclusion (author-owned PR; GitHub blocks formal self-approval).
这是范围适当的完整一致性修复。long_horizon 判断为 improved:关闭状态的矛盾工作与扣费标志在读取和新 Envelope 构造前被拦住,合法后续工作保留原来的 fresh-Turn 路由。user_experience 判断为 improved:相同合同不再让不同读取入口给出矛盾结论,非阻塞通知没有变成用户门禁。语义采用现有合同与诊断家族,local_only 新增 settled-spend 诊断;没有全局 mode enum 或额外权限模型。未来导向整理已完成于这组重复规则,更广调度迁移、选择准入和整体 Goal 验收仍保留原 owner。小幅传输成本是明确取舍,CI 与维护者合并授权仍单独保留。
English verdict: APPROVE - acbd371; one typed consistency owner rejects closed-contract work/spend contradictions across real consumers while preserving valid outputs; 165 Python and 34 TypeScript tests pass, CI remains queued.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent | gpt-6.1-sol | OpenAI | runtime_reported | xhigh
APPROVE — 本次精确 head 未发现阻断问题;这是已复现的瞬时合同一致性修复,不是生产错误扣费的证明。
动机
运行 quota、Effect 解释器或构造下一轮执行输入的宿主与维护者。一轮已经结算后,旧消费者仍接受同一个 packet 中的再次执行或扣费标志,调度仲裁与执行输入的解释因此可能矛盾。修复让这些消费者共同拒绝矛盾输入,合法历史读回、普通工作与非阻塞通知继续可用,维护者无需手工同步两套判断。29组相同输入经过调度仲裁、Effect解释器、scoped override和TurnEnvelope四个实际消费者;基线14组失败,候选源码及独立wheel全部通过,15组合法输入完整输出相等。真实File/SQLite CLI结算回放及安装包准入可读回。本批交付既有交互合同的瞬时一致性校验;不新增执行或收费权限,不迁移或重写回执,不声称生产发生过错误扣费,不关闭整个语义收敛计划或资格化在线模型/App/Lark体验。
改动思路
把已有TS交互合同中的校验复用为一个纯规则,同时删除Python重复语义,能同时修复四个真实消费者;只给TurnEnvelope再加一个if会继续留下不同判断。Python仍持有结构诊断与cadence投影,不新增第二个authority或持久状态。当前PR只收敛关闭模式的执行/扣费一致性、注册现有runtime调用与保留历史缺省,并一并交付反例和双语行为说明;Todo选择准入与更广的语义迁移保留原owner。不修改已有的 quota/lease/receipt 权威事务;这层只是从完整输入推导一致性诊断。scheduler 的累积结构错误与 TS decoder 的首错误抛出仍各自保留,semantic 顺序共享。运行时不可用必须显式失败,不能回退到另一份 Python 判断。
具体改动
关键代码讲解
- interactionConsistencyIssues 按 delivery、quiet、terminal、settled-open、settled-spend 的顺序生成诊断。关闭模式匹配既有完整 literal,显式布尔事实决定结果,没有 substring denylist。
- projectInteractionConsistencyValidation 把已有 Python 仲裁的归一化事实送到同一规则,仅返回错误码;新 runtime handler 不取得执行、租约或收费权。
- decodeInteractionContract 先保留原 user/agent 严格解码,再验证 mode 和 cli spend。字段缺失仍为 false;显式字符串 false 会拒绝。Effect interpreter、scoped override 与 TurnEnvelope 在签署前都经过这里。
- build_scheduler_arbitration 删除重复 Python 语义 if,保留结构错误顺序、CONSISTENCY_REPAIR 及既有 cadence 分类。并非将调度器整个迁到第二个 helper。
验收依据为 docs/reference/effect-interpreter-packet.md,不可变版本 df826263926651ab9c50acee182ef96e2a60ff4b,先读接受合同再看候选实现。read-only-lens 已实现:四消费者不授予副作用权;terminal-closeout-order 已实现:关闭状态的两种 spend flag 均拒绝;existing-around-decisions 已实现:既有 quota/settlement/cadence owner 和历史回读保留。新增文档披露瞬时接受条件的加强,不用候选文档反向定义旧验收。更广的 #4447 收敛并未关闭。
对主干的风险
最强反例是修复只挡住非法输入,却误拒绝合法已结算回放、旧 packet 或通知。独立冻结 oracle 使用同一输入与四个真实消费者:基线 14 个场景共 52 个拒绝断言失败;候选源码与源目录外独立安装 wheel 各 29/29 通过,15 个合法场景的完整结果不经语义归一化即一致。其中包括普通工作、四类合法关闭状态、缺失扣费字段、非阻塞 NOTIFY 和独立 capability intent。
独立运行 103 项相关 Python 测试、21 项 CLI adapter/回放测试、29 项 TS 测试、control-plane typecheck、公共 interaction scheduler smoke、Ruff 和 diff 检查通过;实际 File→SQLite→新写入/结算→重启→File 旅程通过,独立安装包对两类实际 store 的 exact Todo 与 quota 准入另行回读通过。源码与 wheel provenance 均已核实。图形 App、Lark、在线模型和完整冷启动延迟未资格化;作者报告的温热 RPC 中位数不是本评审的独立性能证明。本批没有 authority-store/provider 重构,没有新增 UI 交互或配置操作,也不靠 CI 结果证明语义。
语义与 CI 对齐
先运行当前 diff 的开发 advisory,再运行完整 semantic smoke,均通过;advisory 不支持该 as-const object,因此空结果不证明没有新语义。人工核验此处复用既有 mode 词汇及 TS owner,只扩展本地 diagnostic,不增加共享 state/schema。完整检查保留 45 个 unresolved producer site,未称整个收敛完成。CI 未查询、轮询或等待;本地必要验证与平台 merge gate 分开。
我的整体评价
把已有TS交互合同中的校验复用为一个纯规则,同时删除Python重复语义,能同时修复四个真实消费者;只给TurnEnvelope再加一个if会继续留下不同判断。Python仍持有结构诊断与cadence投影,不新增第二个authority或持久状态。当前PR只收敛关闭模式的执行/扣费一致性、注册现有runtime调用与保留历史缺省,并一并交付反例和双语行为说明;Todo选择准入与更广的语义迁移保留原owner。long_horizon=improved:未来规则只需改共同 owner,合法 settled 读回和下一工作保持;user_experience=improved:原入口给出一致拒绝与修复,不增加配置或人工确认。bounded future-facing pass 已应用:删除 Python 重复语义,保留结构诊断和 cadence 的合理独立职责,不再抽象出新的通用规则框架。额外 readonly RPC 的完整成本和真实外部界面采用不据小样本宣称通过。所有结论绑定 acbd371a9c7f5fb919762f0344e3188f6df78672;当前精确 head 的有界修复可批准,合并仍需当前 owner、平台保护和权限;本评审不合并。
English verdict: APPROVE
|
Reviewer: model_agent | gpt-6.1-sol | OpenAI | runtime_reported | xhigh English verdict: APPROVE MotivationA host reading an already settled quota packet could previously accept flags for another action or spend. The Python scheduler and typed interpreter/envelope consumers also disagreed about closed-mode work flags. This review reproduced contradictory synthetic inputs; it does not establish that a production charge occurred. The patch supplies consistent refusal through the existing callers while preserving valid work, old omitted metadata and notification-only readback. DesignThe existing TypeScript interaction-contract owner now supplies a pure ordered consistency rule. Python transports normalized facts through the existing Effect runtime and retains structural diagnostics and cadence selection. This removes its duplicated semantic rules. A separate envelope-only guard would leave the other readers inconsistent. There is no additional state store, process strategy, optional capability activation or execution grant. Changes and acceptance
The independently inspected accepted basis is Main risks and validationThe independent same-input oracle exercised all four actual consumers at immutable base, exact head and an isolated installed wheel. Fourteen baseline cases failed 52 refusal assertions; head/wheel passed all 29 cases. Fifteen legal complete observations were identical without semantic normalization, including ordinary work, valid closed modes, historical absent flags, NOTIFY without required action and independent capability intent. This tests both missed refusal and overblocking. Independently passed: 103 focused Python tests,21 adapter/replay tests,29 TypeScript tests,typecheck,public scheduler smoke,Ruff,diff and full semantic smoke after the diff advisory. A real File→SQLite→new write/settlement→restart→File CLI journey passed; separate installed-python-I processes read exact Todo authority and quota admission from both stores. Wheel assets were normally built/verified and package provenance was outside source. The advisory does not parse this as-const object; manual vocabulary assessment complements it. The full semantic check retains45unresolved producer sites rather than certifying their safety. Graphical App,Lark,paid provider adoption and end-to-end cold latency were not qualified. Author warm fixture timings are not this review's independent performance result. No authority-store refactor/new UI interaction is claimed. CI was not fetched,polled or awaited. Overall assessmentThe bounded repair is useful,proportionate and in the existing owner. Sustained operation and user readback improve because one rule prevents consumer disagreement without another configuration or manual confirmation. The related future-facing refactor is already applied:delete duplicate Python semantics while retaining distinct structural/cadence responsibilities. This local diagnostic extension adds no actor lifecycle,lease or charging authority. APPROVE is bound to |
A quota packet marked as already settled could still carry an immediate or post-validation spend flag into a newly constructed TurnEnvelope. The TypeScript readers also accepted open-work flags in closed modes that Python scheduler arbitration rejected. These are reproduced contradictory-input cases, not a claim that an unintended production effect occurred.
The existing TypeScript interaction-contract owner now supplies the consistency rules for the scheduler, Effect interpreter, scoped-override projection and TurnEnvelope construction. Python transports normalized facts and retains structural diagnostics and cadence selection; its duplicate semantic rules are removed. Closed modes reject both spend flags. Missing flags retain the historical false default, and present flags must be boolean. Valid work, independent capability intent, recovery guidance and stored receipts keep their contracts.
This extends the existing local diagnostic contract with a settled-spend contradiction code; it adds no Goal, lease or execution authority. The internal method is named
interaction_consistency.validateto make that boundary explicit. English/Chinese guidance documents the strengthened validation. Refs #4447 for the bounded convergence work; rejected/deferred selection admission and the tracker's broader source evidence remain separate work.Validation:
The changed user-facing contracts are rejection/readback on existing CLI/Effect/Envelope paths; there is no new UI interaction or configuration switch. Isolated synthetic tests do not establish installed-App, Lark or live-provider qualification. CI and maintainer merge remain separate gates.