Repository navigation
fix(replan): treat same-second review-bound successors as post-admission - #8731
Conversation
Canonical Todo timestamps are whole seconds. A review-bound successor created in the admission second was stored earlier than a fractional guard_recorded_at, so lifecycle reconstruction dropped the admitted source and receipt-bound recovery could not settle the original Turn. Compare that successor with the same admission-second bound closeout already uses. Earlier seconds, a different review, and missing or invalid timestamps still keep the inferred edge. Signed-off-by: Duang777 <duangjl007@gmail.com> Co-authored-by: DDL <duangjl007@gmail.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max
Reviewed commit: 6b15568faa435a9b8e1a9f7c083f163e68d12386 · merge base 78e936f9d1f1a00505c4026ee0a5857de95cee27.
无阻塞发现。 同秒后继在两种实际存储上可完成原轮恢复。之前失败的原轮结算和后继准入均已独立复验。
动机 / Motivation
生命周期复核先得到准入回执。添加依赖后继后,操作者重新进入原 Turn 并完成原始交付。 在 Todo 仅记录整秒的条件下,同秒创建且有原复核义务的后继仍能恢复原轮;错归属或早于该秒的依赖不取得此待遇。
在分支基线,准入回执是带小数的时间,真实 Todo 落盘按整秒。原轮重入把同秒后继当作先存在的边,SQLite 和 File 均报 heartbeat_receipt_identity_conflict。 File、SQLite 的前一秒负例都不能产生 settlement-only 行动,也没有额外扣额。后一秒在基线与当前提交均可完成。用同一输入经 Python 到 TypeScript 的运行时入口验证 resume_when 和 unblocks_todo_id,错误 owner、actor、obligation 以及非法或缺失时间均保留既有依赖边。
在两个独立安装的 Core wheel 上,真实 Todo 创建仅在提供方时间入口注入同秒时间。当前提交恢复并验证原回执身份,写回、一次扣额和后继执行均通过。分支基线同样两组在原轮重入失败。 Core 以两份单独构建并安装的源码 wheel 验证,文件与 SQLite 存储正常写入。只注入合成 Todo 的时间输入,未运行托管 CI 或连接真实模型。
改动思路 / Approach
Todo 提供方保存整秒更新时间。既有 lifecycleSource 重建可用来源,使用同一个 admissionSecond 判断复核后继与终态关闭;精确义务摘要、完成身份和同一 Agent 约束继续决定是否能接着结算。 Core 以两份单独构建并安装的源码 wheel 验证,文件与 SQLite 存储正常写入。只注入合成 Todo 的时间输入,未运行托管 CI 或连接真实模型。 时钟只注入到合成 Todo 的入口;回执、Todo、写回与扣额仍由正常安装 CLI 持久记录。
具体改动 / Changes
依据 docs/reference/protocols/goal-vision-replan-contract-v0.md 在 87a736bd4a9234096b68697d108a5bb5ed1af8ce 的条款。既有整秒恢复用原摘要证明来源。相邻兼容时间线分别跑同秒、前一秒和后一秒。 规范
- same_second_preserves_origin · 通过。同一原复核绑定的同秒后继保留原轮完成证据、写回与一次结算。
- older_or_foreign_keeps_edge · 通过。早一秒、身份不符或时钟缺失的边仍参与原有选择。
- new_turn_owns_successor · 通过。恢复只结算原轮,后继工作仍由下一轮准入。
关键代码讲解
- 用已存在的整秒界限规范原回执时间。 admissionSecond
- 同一义务、同一 owner/actor 且不早于准入秒时,保留当时的来源。 reviewSuccessor
- 重建后仍核对原始触发项与完成身份。 lifecycleObligation
- 复用原义务摘要与当前已有的确切后继证据。 receipt_bound_lifecycle_candidate
另有问题来源和原有边界可对照。 已合入的接续恢复
对主干的风险 / Risks
基线和当前头各有 7 项 Python 与 36 项 TypeScript 通过。同秒独立安装对照从两组失败变为两组通过,前一秒拒绝与后一秒通过在两侧各有两组。 Git 差异检查、分支签署与检查时主干的模拟合并均通过。Core 以两份单独构建并安装的源码 wheel 验证,文件与 SQLite 存储正常写入。只注入合成 Todo 的时间输入,未运行托管 CI 或连接真实模型。
语义与 CI 对齐
File、SQLite 的前一秒负例都不能产生 settlement-only 行动,也没有额外扣额。后一秒在基线与当前提交均可完成。用同一输入经 Python 到 TypeScript 的运行时入口验证 resume_when 和 unblocks_todo_id,错误 owner、actor、obligation 以及非法或缺失时间均保留既有依赖边。 可重跑 uv run --extra test python -m pytest -q tests/control_plane/test_replan_semantics_transport.py tests/control_plane/test_installed_core_context.py::test_installed_lifecycle_review_recovers_a_late_dependent_successor,并加入上面的对照。
我的整体评价 / Verdict
保留同一类型化生命周期来源和现有回执核验。已证明整秒修复可交付,暂无阻塞修改。 原 guard 的 Goal、Agent、Turn、义务和完成身份约束结算。后继执行用新 Turn,原轮只允许收尾。 真实负例已证明旧边界仍有效,后继工作另有一次准入和回执。
English verdict: APPROVE. Independently installed Core on File and SQLite preserves original same-second lifecycle settlement and debits once. Earlier, invalid, and foreign-successor controls retain the existing fence.
Goal And Delivered Outcome
lifecycleSource()keeps an admitted lifecycle review when a genuine dependent successor is created after admission and bound to that review. Fix standalone successor settlement recovery #8699 addedreviewSuccessorso those successors do not erase the admitted source through inferredresume_when/unblocks_todo_idedges. The fence requiredupdated > admittedat microsecond precision. Canonical Todoupdated_atvalues are whole seconds, and admission receipts often carry a fractionalguard_recorded_at(for example2026-08-01T00:00:01.500Z). A successor created in that same second is stored as2026-08-01T00:00:01Z, soupdated > admittedis false, the inferred edge still drops the source, and receipt-bound recovery cannot settle the original Turn.2026-08-01T00:00:01.500Zplus a review-bound successor atupdated_at: 2026-08-01T00:00:01Zreconstructed{items: [], settled: false}. After, the same input preserves the original row ({items: [row], settled: false}) and receipt-bound recovery still settles that original Turn. A later second (2026-08-01T00:00:02Z) still preserves the source. An earlier second (2026-08-01T00:00:00Z), a different obligation, the wrong owner or actor, and an invalid or missing timestamp still yield an empty source.mainat78e936f9d1f1a00505c4026ee0a5857de95cee27.Author Declaration
Implemented against
lifecycleSource()(updated >= admissionSecond) is the existing whole-second rule this fence now shares.lifecycleSourceinloopx/control_plane/work_items/replan_semantics.tstests/control_plane_ts/replan_semantics.test.ts;tests/control_plane/test_replan_semantics_transport.pytest_installed_lifecycle_review_recovers_a_late_dependent_successortests/control_plane/test_installed_core_context.pymainbefore editing; read the closeout comparison inlifecycleSource(); ran the commands in Validation. Did not run the full control-plane suite or the rest oftest_installed_core_context.py.Scope And Continuation
reviewSuccessorare unchanged. Complete within this scope.Validation
6b15568faa435a9b8e1a9f7c083f163e68d12386regression_paritypassedlifecycle_sourcecall withguard_recorded_at: 2026-08-01T00:00:01.500Zand a review-bound successor atupdated_at: 2026-08-01T00:00:01Zreturned{items: [], settled: false}. The assertion that it preserve the original row failed.2026-08-01T00:00:02Zpreserved the row;2026-08-01T00:00:00Zstayed empty.unitpassednode --no-warnings --experimental-sqlite --experimental-strip-types --test --test-concurrency=4 tests/control_plane_ts/replan_semantics.test.ts— 36 passed, 0 failed.staticpassednpm run typecheck:control-plane— exit 0.unitpasseduv run --extra test python -m pytest -q tests/control_plane/test_replan_semantics_transport.py— 7 passed. Coversreceipt_bound_lifecycle_candidatefor both2026-08-01T00:00:02Zand2026-08-01T00:00:01Z, and rejects2026-08-01T00:00:00Z.real_entrypointpassedloopx-corewheel, thenuv run --extra test python -m pytest -q tests/control_plane/test_installed_core_context.py::test_installed_lifecycle_review_recovers_a_late_dependent_successor— 2 passed (sqlite and file). This path still sleeps so the successor is stamped on a later whole second.staticnot_applicablereceipt_bound_lifecycle_candidate. The installed test still qualifies the real CLI recovery journey for a later whole second; it does not force the successor into the admission second. A fractionalupdated_atinside the admission second but earlier thanguard_recorded_atis not a canonical Todo write and is not separately asserted.Frontend / Visual Evidence
Type of Change
LoopX Area
Technical Direction
Shared-authority RFC fixture impact
Boundary Checklist
.loopx/,.codex/goals/, and liveACTIVE_GOAL_STATE.md).python3 scripts/check_rfc_bilingual.py --base origin/main --head HEADpasses, or no paired RFC changed.none.Signed-off-bytrailer (git commit -s).The unchecked scope box is intentional: there is no linked issue. The change is limited to this residual fence.
Remaining risk
A timestamp in the admission second is now post-admission for a review-bound successor, including a fractional value earlier than
guard_recorded_atbut still inside that second. That matches closeout, and the review id does not exist before admission. An earlier whole second is still rejected, so a clock that stamps the successor in the previous second still drops the source. The installed CLI qualification waits one second and therefore does not itself force the same-second case; the deterministic same-second proof is the behavior tests above.