Skip to content

fix(replan): match a null admitted completion key to a Todo row without one - #9296

Merged
loopx-agent merged 1 commit into
loopx-project:mainfrom
xiaobaifly7:fix/core-replan-null-turn-key
Nov 23, 2026
Merged

loopx-agent merged 1 commit into
loopx-project:mainfrom
xiaobaifly7:fix/core-replan-null-turn-key

Conversation

@xiaobaifly7

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

  • Outcome basis / optional anchor: reproduced defect (LoopX 2.4.0 from PyPI and main at b03763b).
  • Goal/source and gap: an autonomous-replan obligation admitted for a completed Todo that has no completion turn key records its trigger as completion_turn_key: null, because goal_frontier builds it with item.get("completion_turn_key"). The Todo row read back for lifecycle reconstruction omits the key, and lifecycleObligation compared the two with !==, so null !== undefined rejected the exact admitted lifecycle.
  • Observable before → after: a second quota should-run with the same --turn-instance-id for an admitted autonomous_replan_required Turn. Before: ok: false, effective_action: heartbeat_receipt_write_failed, "lifecycle source does not match the admitted obligation". After: ok: true, should_run: true, autonomous_replan_required. Hosts that revalidate before entering the Turn (the DSH Driver's pre-step recheck) rejected every such Turn, and LoopX paused once all agent Todos were done.
  • Issue/task and intended base: none. Base main.

Author Declaration

  • Written by: model_agent, Anthropic Claude (Opus 5.5) in Claude Code, operated by the commit author.

Implemented against

  • Specification and revision: no written specification; the request in this PR is the basis. The Python obligation identity (trigger_identity in autonomous_replan_obligation.py) already treats a None completion key as absent, and this change aligns the TS comparison with it.
  • Criteria:
Criterion (spec clause) Disposition Symbol / path Test or command
A null admitted key matches a row without the key implemented lifecycleObligation in replan_semantics.ts tests/control_plane_ts/replan_semantics.test.ts "an admitted lifecycle trigger with a null completion key matches a Todo row without one"
A key present on only one side still conflicts implemented same same test
Receipts already admitted with a null trigger recover implemented comparison-side fix same test (trigger built with null)
  • Self-check before submission: the new test fails on main with "heartbeat receipt settlement identity conflicts" and passes here. Neighbouring TS and Python tests and the control-plane typecheck were run. Other completion_turn_key equality checks in the TS control plane were reviewed; they already normalize to null or require a non-empty string. The admission side was left unchanged: changing it would not repair receipts already recorded with null.

Scope And Continuation

  • Completed scope and remaining work: complete within this scope.
  • Slice boundary / successor: N/A

Validation

  • Tested revision: 50b264d
  • Run state: finished
  • Input classes: synthetic, authorized_private_read_only
Check kind Result Public-safe evidence / limitation
unit passed node --no-warnings --experimental-sqlite --experimental-strip-types --test tests/control_plane_ts/replan_semantics.test.ts: 42/42; on main the new test fails
unit passed tests/control_plane_ts/replan_settlement.test.ts 10/10, tests/control_plane_ts/quota_settlement_readback.test.ts 169/169
static passed npm run typecheck:control-plane
integration passed tests/control_plane/test_lifecycle_guard_reentry.py, test_replan_settlement_runtime.py, test_replan_semantics_transport.py: 43 passed, 6 failed; the same 6 fail on main on the Windows author host (sqlite legacy writer fence "value must be strict JSON")
real_entrypoint passed Read-only copy of a real install state: unpatched b03763b runtime revalidation ok:false / heartbeat_receipt_write_failed; the same runtime with only this line patched returns ok:true / should_run:true / autonomous_replan_required. Private state, not attached.
  • Coverage and gaps: the end-to-end check used b03763b plus this one-line change, not a build of this exact commit. main's replan_semantics.ts is identical to b03763b's.

Frontend / Visual Evidence

  • UI impact: none

Type of Change

  • Bug fix

LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)

Technical Direction

  • Direction / acceptance reference, when applicable: N/A

Shared-authority RFC fixture impact

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.
  • 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.
  • No paired RFC changed.
  • UI impact none.
  • Every commit includes a DCO Signed-off-by trailer (git commit -s).

🤖 Generated with Claude Code

…ut one

An autonomous-replan obligation admitted for a completed Todo that has no
completion turn key records the trigger as `completion_turn_key: null`
(goal_frontier builds it with `item.get("completion_turn_key")`). The Todo
row read back for lifecycle reconstruction omits the key, and
`lifecycleObligation` compared the two with `!==`, so `null !== undefined`
rejected the exact admitted lifecycle. A second `quota should-run` for the
same `--turn-instance-id` then failed with `heartbeat_receipt_write_failed`
("lifecycle source does not match the admitted obligation"). Hosts that
revalidate before entering the Turn, such as the DSH Driver's pre-step
recheck, rejected every such Turn.

Compare the key as `?? null` on both sides. This matches the Python
obligation identity, which already drops a None completion key, and it
also repairs receipts already admitted with a null trigger, which an
admission-side change would not. A key present on only one side still
conflicts.

Signed-off-by: xiaobaifly7 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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 · xhigh

动机 / Motivation

在进入已准入重规划轮次前复查的宿主,需要核对同一个旧 Todo 和原回执。 旧 Todo 缺少完成轮次键时,准入触发记录 null,随后读取的 Todo 省略键。基线第二次检查因此拒绝已经准入的轮次。 同一条公开 CLI 命令能复查原轮次,并读回相同的 effect 身份和触发序列。真实 File 和 SQLite 结果一致。 只修复重规划来源比较。既有 Todo 状态、凭据版本、写回与额度规则仍由原有入口处理。

改动思路 / Approach

现有权威和消费者足以解决问题。Python 准入保留既有触发数据。TypeScript 只调整匹配器对两个缺值表示的语义,未改变原始 JSON 或真实键。无需新状态、迁移或把错误分支转成成功。 只修复重规划来源比较。既有 Todo 状态、凭据版本、写回与额度规则仍由原有入口处理。 原先的匹配前提仍适用。失败输入继续走原有拒绝路径,只有满足现有约束的记录才能完成这一步。已有完成键的匹配保持精确。两种存储的带键对照在基线和当前头都成功,一侧有键仍拒绝。

具体改动 / Changes

精确头的净差异为两个文件 +28/-1。生产代码在已存在的匹配函数中处理当前场景,测试加入正常回读、失败或不匹配边界。Python 准入保留既有触发数据。TypeScript 只调整匹配器对两个缺值表示的语义,未改变原始 JSON 或真实键。 依现有合同核验了 original_9296_contract 和 unchanged_negative_gate,两个约束均有执行证据。当前主干与精确头的三方合成未产生冲突。 现有合同

关键代码讲解

  • lifecycleObligation 确认原收据的触发对象和完成身份。只把缺省和 null 视为同一个缺值。 源码
  • projectReplanSemantics 原生重规划复查的投影入口。继续使用原有来源、Agent、Todo 和触发序列约束。 源码

对主干的风险 / Risks

PASS。四个真实 CLI 用例通过。带有效完成键和不带键的 Todo 在 File、SQLite 都能复查同一轮,不产生额度扣减。 在基线的实际 CLI 上,两个无键用例均失败,有真实键的两个对照通过。当前 TypeScript 反例也拒绝仅一侧有键的记录。 精确头 221 项 TypeScript 测试、四个原生 CLI 对照及 TypeScript 类型检查通过。全树检查在补齐独立检出的 TypeScript 依赖后通过。主干的 Goal frontier 重构合成后重跑,四个原生对照仍通过。 快速预合并 4 项直接检查通过,选中检查 3 项通过。 适用范围与残余风险已限定。验证使用隔离的 File 和 SQLite 源码运行。未运行正式安装、Windows 或 PostgreSQL。

语义与 CI 对齐

使用现有协议、既有匹配条件和状态投影。已有完成键的匹配保持精确。两种存储的带键对照在基线和当前头都成功,一侧有键仍拒绝。 比较原实现与当前头的结果,没有依赖远端 CI。 回归测试

我的整体评价 / Verdict

没有阻止批准的问题。该改动恢复了正常且已经获准的后续路径,降低合法工作因数据形状中断的风险,保留错误、授权、写回和调度约束。改动只涉及重规划投影和 CLI 复查,未改动渲染页面。 验证使用隔离的 File 和 SQLite 源码运行。未运行正式安装、Windows 或 PostgreSQL。

English verdict: APPROVE at 50b264d. Native File/SQLite recheck preserves the original Turn for absent completion keys while keyed and mismatch controls retain their semantics.

@xiaobaifly7

Copy link
Copy Markdown
Contributor Author

The two red checks here come from one cancelled job: dashboard-browser (1) was cancelled ("The operation was canceled", job 137529181370), and the aggregate checks job then fails on dashboard-acceptance must be success. This PR only touches replan_semantics.ts and its test, and dashboard-browser passed on #9297 in the same window. Could a maintainer re-run the failed jobs? I don't have permission to.

🤖 Generated with Claude Code

@loopx-agent
loopx-agent merged commit 62515d5 into loopx-project:main Nov 23, 2026
40 of 48 checks passed
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