Repository navigation
fix(decision-context): settle reviewed facts without action authority - #9137
Conversation
Signed-off-by: huangruiteng <[email protected]>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google DeepMind · self_reported
已基于 origin/main(eb552a8bb0532de117513ee5277a92e74e746309)与精确远端提交 57e5b175cf3b170cd25f0a769617a326d643ab0b 完成全文 diff 审查、基线对照与本地实测验证,结论为 APPROVE,未发现阻塞合并的 P1/P2 缺陷。
动机 / Motivation
本次改动面向在 Decision Context 增量采集与复核流程中调用 settle_profile_decision_review 或 loopx decision-context settle-review 的 Agent 与私有适配器。在原有实现中,当增量来源读到新事实(semantic_rebase 为 material_change)但审阅后判断无需发起行动建议时,系统只有用户门控事件(approve / reject / defer)与语义 no_change 两条退出路径。
变更前:当增量来源产生新事实(material_change)但无需提出行动建议时,省略 --source-event-id 会回退为 no_change 并因缺少 semantic_no_change 证明报错,导致私密 cursor 无法推进且采集队列一直残留待处理批次;变更后:显式传入 --disposition observed 即可在验证 material_change 语义重算后提交私密 cursor 并释放采集批次,同时保持 authority_confirmed=false 与 quiet_noop=false。这带来了明确的收益:新增显式 observed 处置状态:支持无 --proposal-json 与 --source-event-id 的事实复核结算,校验 semantic_rebase 为 material_change 且 quiet_noop_allowed 为 false,写入 quiet_noop=false 的 validation 事件并完成 CAS cursor 提交与采集批次释放。同时,PR 边界克制:不引入新的自动化审批或行动授权,不修改 Core user_gate/todo/quota 语义,不默认开启 Decision Context,也不扩展到 Outcome Receipt 或 Reward Memory 候选自动入库。
改动思路 / Approach
PR 直接复用 Decision Context 既有责任分层,没有另建平行状态文件或采集退役分支:本改动严格复用 packets.py、cursor_commit.py、review_settlement.py 与 cli.py 的既有职责边界,未新增并行状态机、未泄漏原始正文、也未授予任何行动权限。其中,因为仅靠 material_change 无法区分“审阅后刻意不行动”和“误漏了 user gate 提案”,显式传入 observed 属于不可归约的调用方意图,而是否具备结算资格则直接由既有的 semantic_rebase.status 与 quiet_noop_allowed 派生。当前 PR 边界聚焦在为无行动建议的新事实评审增加显式 observed 结算通路并释放采集批次,不触及 Outcome Receipt 与 Core gate 逻辑。
| 结算路径 | 是否需要 --proposal-json / --source-event-id |
允许的 semantic_rebase 前提 |
authority_confirmed |
quiet_noop |
|---|---|---|---|---|
approve / reject / defer |
必须匹配有效 user_gate 事件与提案 |
不要求 no_material_change |
true |
false |
no_change(省略 --disposition 默认值) |
禁止传入 | status == "no_material_change" 且 quiet_noop_allowed is True |
false |
true |
observed(本次新增) |
禁止传入 | status == "material_change" 且 quiet_noop_allowed is False |
false |
false |
具体改动 / Changes
全量改动共 11 个文件(+203/-22):4 个 Python 运行时模块(+53/-9)、4 份中英文协议与能力文档(+28/-11)、3 个测试文件(+122/-2)。
关键代码讲解
DECISION_REVIEW_DISPOSITIONS(loopx/capabilities/decision_context/packets.py#L37-L43):在规范集合中新增"observed",保持封闭集合校验。build_decision_review_receipt(loopx/capabilities/decision_context/packets.py#L470-L560):将门控判断显式收束为gated = normalized_disposition in {"approve", "reject", "defer"};对"observed"同样禁止绑定proposal_packet_ref、gate_todo_id、source_event_id,且固定输出authority_confirmation_required=False、authority_confirmed=False、outcome_observation_required=False,并仅在"no_change"时将quiet_noop设为True。_validate_review_packet_chain(loopx/capabilities/decision_context/cursor_commit.py#L197-L296):保留no_change对no_material_change+quiet_noop_allowed=True的严格校验,新增observed分支要求semantic_rebase.status == "material_change"、quiet_noop_allowed is False且proposal is None;空 rebase("incomplete")仍被两条无门控路径拒绝。settle_profile_decision_review(loopx/capabilities/decision_context/review_settlement.py#L22-L155):新增可选参数disposition: str | None = None。传入source_event_id时禁止覆盖处置结果;未传source_event_id时拒绝proposal,缺省仍回落为"no_change",显式传入只允许{"no_change", "observed"};预览与写入前统一调用_validate_review_packet_chain,并在validation事件和返回包中将quiet_noop设为disposition == "no_change"。register_decision_context_commands/handle_decision_context_command(loopx/capabilities/decision_context/cli.py#L243-L275,#L420-L447):在settle-review子命令新增--disposition(choices=("no_change", "observed"),默认为None)并透传给settle_profile_decision_review。
依据规范文档 docs/reference/protocols/decision-context-architecture-v0.md(不可变基线 eb552a8bb0532de117513ee5277a92e74e746309):
DC-INV-3(无行动授权隔离):implemented(packets.py#build_decision_review_receipt,由test_observed_review_records_facts_without_authorizing_action验证)。DC-INV-8(结算校验与写入后方提交私密游标):implemented(cursor_commit.py#_validate_review_packet_chain,由test_material_review_cli_releases_capture_without_authorizing_action验证)。DC-INV-9(无门控结算必须具备有效语义重算证明而非空 rebase):implemented(review_settlement.py#settle_profile_decision_review,由test_observed_settlement_requires_material_review_before_any_write验证)。- PR 同步修订规范中
decision_review_receipt_v0以容纳observed,属于消除真实采集死锁的合理补齐,且未放宽任何 Core 权限约束。
语义与 CI 对齐
经核查 loopx/semantics/vocabulary_v0.json 与已通过的 examples/semantic-vocabulary-drift-smoke.py,本次仅扩展能力内部封闭词表 DECISION_REVIEW_DISPOSITIONS(extend_vocabulary),未改写跨控制面词汇表,也未改变 semantic_rebase.status 取值,满足仓库语义对齐与默认关闭隔离约束。
对主干的风险 / Risks
未发现阻塞主干合入的 P1/P2 回归风险。围绕最强失效与绕过场景进行了本地验证(均为 PASS):
- 负向与门控防绕过校验:实测确认当省略
--disposition结算material_change时仍按no_change拒绝;将observed用于空 rebase(incomplete)或semantic_no_change=True时在预览及执行阶段均于写入前抛出ValueError;observed与proposal或source_event_id混用、或未提供source_event_id传入disposition="approve"、以及篡改quiet_noop_allowed=True均被拒绝且不改动事件日志或私密 cursor。 - 端到端采集闭环与幂等重放:
test_material_review_cli_releases_capture_without_authorizing_action与基线对照实验验证settle-review --disposition observed在预览时不落盘,在--execute时写入validation事件并原子推进私密 cursor,重复执行返回status="replayed",随后capturetick 成功清除待审批次并在后续文件再次修改时恢复捕获新批次。 - 残余与非阻塞边界:
decision-context-architecture-v0.{md,zh-CN.md}中 Mermaid 图(L139)与流程说明段落(L236-L238、L274-L275)、README.{md,zh-CN.md}摘要条目(#5 与成熟度总结)、catalog_entry.py#L146及examples/decision-context-contract-smoke.py仍主要列举四类旧处置名称;另外mypy --follow-imports=silent在未修改的cli.py:381存在基线既有类型报错,本次修改行及另外 3 个运行时文件均为 0 报错。
我的整体评价 / Verdict
判定:精确覆盖范围清晰、默认关闭隔离完整(inspect-profile 禁用态及省略 --disposition 行为与 origin/main 完全等价)、未新增冗余状态或外部副作用,建议 APPROVE。
- 长程与用户体验评估(
outcome_impact):long_horizon=improved(打通非行动新事实的周期性采集与游标推进闭环,防止采集队列长期堆积阻塞);user_experience=improved(避免为纯阅读性变化强行打断 owner 审批,同时保持默认兼容)。界面视觉评审说明:本次变更为后端 Python 能力契约、CLI 参数与中英文文档,未修改 apps/ 下的前端或聊天展示界面。不存在未验证的 UI 界面范围(unverified_scope: none)。 - 词汇与体积结论:沿用既有关联词表并小幅扩展
DECISION_REVIEW_DISPOSITIONS(extend_vocabulary),运行时净增仅+53/-9,无需拆分或重写;建议后续单独小步补齐架构文档中剩余 2 处枚举摘要与examples/decision-context-contract-smoke.py对observed的覆盖。 - 本地验证记录(未依赖远程 CI):
tests/capabilities/test_decision_context_*.py+tests/test_decision_context_material.py+tests/presentation/test_decision_context_api.py+tests/test_capability_code_maps.py:PASS(230 passed, 0 skipped)- 含
tests/test_windows_atomic_writes.py联合测试集:PASS(236 passed;3 skipped 均为 macOS 环境下 Windows 扩展路径 IO 用例) tests/architecture与tests/control_plane公共安全测试集:PASS(357 passed)examples/decision-context-contract-smoke.py与examples/decision-material-walkthrough-smoke.py(隔离环境):PASSruff check(7 个改动 Python 文件)与check_rfc_bilingual.py:PASSloopx canary premerge --from-git-diff --git-diff-base origin/main --tier standard:PASS(18/18 checks passed, 0 failures)mypy --follow-imports=silent(4 个运行时文件):修改行与其余 3 个文件 0 错误;cli.py:381存在基线既有的 1 处类型赋值报错- 不可变基线(
eb552a8bb0532de117513ee5277a92e74e746309)vs57e5b175cf3b170cd25f0a769617a326d643ab0b行为对照:PASS
English verdict: APPROVE
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI (runtime_reported, xhigh)
动机 / Motivation
持续读取 Decision Context 来源的维护者,需要确认已复核的新事实并腾出位置继续采集。 遇到有实质变化但无需发起行动的证据,旧 CLI 没有相应的结算方式,尝试显式结算会被拒绝。 候选允许记录已复核的新事实,读回无行动权限的结算回执,并继续采集下一批来源。 独立验证覆盖源码 CLI、隔离的文件来源、SQLite 采集队列和本地事件读回。未复验已安装发行版和外部真实来源。
改动思路 / Approach
复用原有评审结算、游标推进和写回读回,只为现有回执加入一种证据结算状态。 当前交付的结算边界由 loopx/capabilities/decision_context/review_settlement.py 负责。调用者先预览语义校验,再执行原有结算并读回游标。需要行动授权时,原路径仍精确读取已经写下的 owner gate。
具体改动 / Changes
评审精确头 57e5b175cf3b170cd25f0a769617a326d643ab0b。补丁在本次验证使用的主干上可干净整合。
关键代码讲解
material-evidence-only-settlement由现有结算入口验证待处理的证据和语义重算。只有真实材料变化可进入observed,回执拒绝 proposal 和 gate 引用。通过校验后,执行沿用验证事件、游标写回和读回。 结算入口 回执 游标验证verified-gate-and-no-change-parity沿用原有 gate 指向和无实质变化判定。CLI 未传 disposition 时维持现有行为。 基线协议 新增回执 写入前校验
对主干的风险 / Risks
精确头和当前主干本地整合树分别通过 111 项。把同一个 CLI 回归放到基线,解析器明确拒绝 --disposition observed。 空 rebase 和无实质变化的 rebase 都不能以 observed 结算。预览和执行都拒绝,事件和游标文件未创建。 隔离 SQL 采集队列在结算后从一批降至零,独立修改来源后重新采得一批。实际回执只含验证事件,authority_confirmed=false。启用分支沿用原 Goal、Agent 和既有游标写回。独立验证覆盖源码 CLI、隔离的文件来源、SQLite 采集队列和本地事件读回。未复验已安装发行版和外部真实来源。
语义与 CI 对齐
扩展的是现有 decision_review_receipt_v0 的 disposition。双语协议公开说明语义,独立矩阵覆盖材料变化、空重算和无变化回归,未查询托管 CI。
我的整体评价 / Verdict
APPROVE。 在已核对的源码路径上,新事实经过复核后可结算并继续采集,旧 gate、quiet no-change 和来源隔离经过回归验证。已安装发行版和外部真实来源仍待验证。
English verdict: APPROVE at 57e5b175cf3b170cd25f0a769617a326d643ab0b. Material evidence can be settled without conferring action authority. Preview rejects missing material proof and existing gated and quiet paths passed regression tests.
Goal And Delivered Outcome
Captured sources can contain reviewed new facts without warranting an action proposal. Previously, settlement required either a user-gated proposal or semantic
no_change, so this ordinary review could not advance its cursor and release the captured batch.This adds an explicit
observeddisposition under the existing Decision Context owner. It requires a material-change semantic rebase, rejects proposal/gate references, and grants no action authority. Preview and execution validate the review chain before appending an event. The existingno_changedefault and event-derived gated dispositions remain supported.main.Author Declaration
model_agent.docs/reference/protocols/decision-context-architecture-v0.mdateb552a8bb0532de117513ee5277a92e74e746309; the reproduced repair request in this PR is the basis for the additional disposition.packets.py,review_settlement.py,cli.pyinloopx/capabilities/decision_context/packets.py,cursor_commit.pyScope And Continuation
Complete within the public capability scope. Provider schedules and semantic review remain owned by their integrations. The new disposition does not infer review from collection, authorize an action, or acknowledge unread historical batches. No new provider or parallel state owner is introduced.
Validation
57e5b175cf3b170cd25f0a769617a326d643ab0b(focused tests exercised the identical diff before commit).test_decision_context_packets.py,test_decision_context_runtime.py,test_decision_context_capture.py,test_decision_context_capture_recovery.pyandtest_decision_context_capture_isolation.py.loopx canary premerge --from-git-diff --git-diff-base origin/main: 6 direct checks and 18 selected checks, zero failures or warnings, at the tested commit.npm ci --ignore-scripts, the isolated check and the full standard run passed. Passing validation is not merge authorization.Frontend / Visual Evidence
Type of Change
LoopX Area
Shared-authority RFC fixture impact
N/A: this PR does not claim a TypeScript migration or shared-authority promotion.
Boundary Checklist