Skip to content

fix(replan): treat same-second review-bound successors as post-admission - #8731

Merged
loopx-agent merged 2 commits into
mainfrom
cursor/same-second-review-successor-fdb4
Nov 14, 2026
Merged

loopx-agent merged 2 commits into
mainfrom
cursor/same-second-review-successor-fdb4

Conversation

@Duang777

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

  • Outcome basis / optional anchor: residual defect in lifecycle reconstruction after the review-bound successor fence landed with Fix standalone successor settlement recovery #8699. No issue is claimed or closed.
  • Goal/source and gap: 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 added reviewSuccessor so those successors do not erase the admitted source through inferred resume_when / unblocks_todo_id edges. The fence required updated > admitted at microsecond precision. Canonical Todo updated_at values are whole seconds, and admission receipts often carry a fractional guard_recorded_at (for example 2026-08-01T00:00:01.500Z). A successor created in that same second is stored as 2026-08-01T00:00:01Z, so updated > admitted is false, the inferred edge still drops the source, and receipt-bound recovery cannot settle the original Turn.
  • Observable before → after, with the validation row that proves it: before, admission 2026-08-01T00:00:01.500Z plus a review-bound successor at updated_at: 2026-08-01T00:00:01Z reconstructed {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.
  • Issue/task and intended base: Related to Fix standalone successor settlement recovery #8699. Base is main at 78e936f9d1f1a00505c4026ee0a5857de95cee27.

Author Declaration

  • Written by: duang777 (@Duang777); agent (Grok 4.7)

Implemented against

  • Specification and revision: no written specification; the request in this PR is the basis. The neighboring closeout bound in lifecycleSource() (updated >= admissionSecond) is the existing whole-second rule this fence now shares.
  • Criteria:
Criterion (spec clause) Disposition Symbol / path Test or command
A review-bound successor with the same owner and actor, stamped in the admission second or later, preserves the admitted lifecycle source and receipt-bound recovery implemented lifecycleSource in loopx/control_plane/work_items/replan_semantics.ts tests/control_plane_ts/replan_semantics.test.ts; tests/control_plane/test_replan_semantics_transport.py
An earlier whole second, a different review, the wrong owner or actor, and an invalid or missing timestamp still drop the source implemented same fence same behavior tests
Installed later-second successor recovery stays qualified implemented test_installed_lifecycle_review_recovers_a_late_dependent_successor tests/control_plane/test_installed_core_context.py
  • Self-check before submission: reproduced the empty source on current main before editing; read the closeout comparison in lifecycleSource(); ran the commands in Validation. Did not run the full control-plane suite or the rest of test_installed_core_context.py.

Scope And Continuation

  • Completed scope and remaining work: the same-second review-bound successor now uses the admission-second bound closeout already uses. Other conjuncts of reviewSuccessor are unchanged. Complete within this scope.
  • Slice boundary / successor: N/A. This is the residual timestamp fence; no follow-up owner is required for the reported failure.

Validation

  • Tested revision: 6b15568faa435a9b8e1a9f7c083f163e68d12386
  • Run state: finished
  • Input classes: synthetic
Check kind Result Public-safe evidence / limitation
regression_parity passed Before the fix, a direct lifecycle_source call with guard_recorded_at: 2026-08-01T00:00:01.500Z and a review-bound successor at updated_at: 2026-08-01T00:00:01Z returned {items: [], settled: false}. The assertion that it preserve the original row failed. 2026-08-01T00:00:02Z preserved the row; 2026-08-01T00:00:00Z stayed empty.
unit passed node --no-warnings --experimental-sqlite --experimental-strip-types --test --test-concurrency=4 tests/control_plane_ts/replan_semantics.test.ts — 36 passed, 0 failed.
static passed npm run typecheck:control-plane — exit 0.
unit passed uv run --extra test python -m pytest -q tests/control_plane/test_replan_semantics_transport.py — 7 passed. Covers receipt_bound_lifecycle_candidate for both 2026-08-01T00:00:02Z and 2026-08-01T00:00:01Z, and rejects 2026-08-01T00:00:00Z.
real_entrypoint passed Separately installed loopx-core wheel, then uv 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.
static not_applicable No paired RFC changed, so the bilingual RFC diff gate does not apply.
  • Coverage and gaps: the changed reconstruction path is pinned by the TypeScript behavior test (same-second preserve, later-second preserve, earlier-second / wrong owner / wrong obligation / invalid / null reject, plus receipt-bound settlement) and by the Python transport test through receipt_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 fractional updated_at inside the admission second but earlier than guard_recorded_at is not a canonical Todo write and is not separately asserted.

Frontend / Visual Evidence

  • UI impact: none
  • Before: N/A
  • After: N/A
  • First viewport and preview: N/A
  • States and viewports shown: N/A
  • Source data: none
  • Attention review: N/A
  • Craft review: N/A

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring (no functional changes)
  • Documentation update
  • Test update

LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)
  • Benchmark boundary (adapters, runners, verifiers, scoring, evidence)
  • Capability or extension (providers, adapters, skills)
  • Public docs or presentation surface (README, protocols, dashboard)
  • Build, packaging, installer, or CI
  • Host or runtime integration

Technical Direction

Shared-authority RFC fixture impact

  • Production-scale fixture schema: N/A
  • Semantic dimensions changed, or reviewed no-impact rationale: N/A
  • Provider conformance arms run: N/A
  • Read-only legacy/file/PostgreSQL three-arm rehearsal (required for promotion, runtime-routing, or compatibility-projection changes): N/A

Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths (including .loopx/, .codex/goals/, and live ACTIVE_GOAL_STATE.md).
  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.
  • I kept the change scoped to the linked issue/task.
  • Existing English/Chinese RFC pairs (including ledger entries) both have a diff, and the local premerge check python3 scripts/check_rfc_bilingual.py --base origin/main --head HEAD passes, or no paired RFC changed.
  • I completed the visual evidence section for UI changes, or marked UI impact none.
  • Every commit includes a DCO Signed-off-by trailer (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_at but 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.

Open in Web Open in Cursor 

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 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.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 · 通过。恢复只结算原轮,后继工作仍由下一轮准入。

关键代码讲解

另有问题来源和原有边界可对照。 已合入的接续恢复

对主干的风险 / 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.

@loopx-agent
loopx-agent merged commit 0328211 into main Nov 14, 2026
9 of 11 checks passed
@loopx-agent
loopx-agent deleted the cursor/same-second-review-successor-fdb4 branch November 14, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants