Repository navigation
Preserve subsecond lease evidence for interrupted Turn recovery - #9314
Conversation
Signed-off-by: LoopX Agent <[email protected]>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-astra · OpenAI · runtime_reported · xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
租约更换后,接手中断轮次的执行方需要凭原回执结清这一轮。原回执记在一秒内的第 250 毫秒,接替租约在第 650 毫秒领取。旧版本把领取时间写成整秒,导致合法的恢复请求遭到拒绝。修复后,两个存储后端都能用同一轮的回执免扣额度结清,再次执行也不会追加记录。本次只修复新写入的时间证据。历史记录中已经丢失的毫秒无法还原。
改动思路 / Approach
时间精度由写入租约与传入观测时刻的原有组件负责,判定权继续由原结算校验器持有。本次修改以领取、续租、释放、移交及结算观测的时间为界,沿用现有到期时刻与存储格式。 领取时丢失小数会让新租约看起来早于原回执,只修领取又会让整秒的观察时刻看起来早于续租。在原有校验器里增加时间容差会放过确实错误的先后顺序,因而需要从两端保留实际观测值。
具体改动 / Changes
关键代码讲解
claim_canonical_todo_if_promoted向现有的原子领取事务提供毫秒。单独领取和托管领取最终都经过materializeTaskLeaseAcquire,在同一处写入该执行代次的领取时刻与更新时间。materializeTaskLeaseLifecycle和释放记录使用同一时间格式。续租时保留 725 毫秒意味着在 700 毫秒观察到的结算请求必须被拒绝,不会因同属一秒而被接纳。到期时间继续使用已有的整秒语义。commit_execution_loss_closeout采集当前实际观察时刻,沿用结算校验器对原回执、当前持有方、执行代次以及当前版本的核验。规格映射见docs/product/core-control-plane/state-definitions.md,基线提交f4c27a88b54e9f5daba0d282076328fb30b922ff。Original receipt and no-spend settlement — implemented. 两种存储的真实命令都验证了原身份、待办仍开放、额度未扣以及重放不再追加。
对主干的风险 / Risks
安装包和旧存储可能共存。发生在同一秒的旧记录若只保留整秒,无法从更大的执行代次倒推出领取发生的毫秒,恢复会明确拒绝。测试还让观测时钟退回到最近一次续租之前,并尝试使用旧凭据或其他代理的身份,这些情况都没有写入记录。新增精度会体现在正常的租约读取界面;到期边界、完成待办和扣费仍由各自原有逻辑决定。
我的整体评价 / Verdict
后续轮次可以越过已验证的结算欠账,保留原工作项和原轮次的身份。操作者可以直接执行已有的恢复命令,避免为了等待跨秒而再次领取。 精确基线在两个存储上都把 450 毫秒的释放记录成整秒;安装了本次提交 wheel 的两组相同用例通过。另两组整秒旧记录测试均遭到预期的拒绝。精确提交的三组 Python 回归共 141 项、原生租约回归 92 项通过。标准预检的 6 项直接检查、18 项选定检查与变更质量回执均已通过。此记录为作者侧评审,GitHub 已请求独立审阅,尚待回执。
English verdict: APPROVE 5392b68. New lease records preserve the order required for administrative recovery, with the existing proof checks and no-spend replay intact.
BigDataDZ
left a comment
There was a problem hiding this comment.
独立复核(native Windows)——暂不批准,待 Python 套件在该 head 上跑完
精确核对 head:5392b685f0e7f84a3d082ca5abdf3ea2d665f967。
已核实(代码)
- diff 全读(7 个文件)。
now_local_iso(*, timespec="seconds")是仅限关键字参数,与本 PR 的调用和测试桩一致;被移除的local_authority.now_local没有残留引用;task_lease_record.ts只依赖类型和runtime_timestamp.ts,没有循环依赖。 qualifyReceiptBoundExecutionLossCloseout经parseTodoTimestampMicros把各时间解析成微秒整数后再比较,不是字符串比较;契约里未发现只接受整秒的时间戳正则。- fail-closed 保留:
legacy-clock变体下整秒写入的替代租约被以 "clock is stale or ambiguous" 拒绝。
已核实(native Windows 实跑)
test_replacement_and_closeout_in_receipt_second→ 4 passed(file/sqlite × precise/legacy-clock,无跳过)tests/control_plane_ts/task_lease_*.test.ts(不含task_lease_inspection)→ 88 pass / 0 fail / 2 skippedtest_execution_loss_closeout_cli.py+test_task_lease_worktree.py→ 19 passed / 2 failed / 20 skipped
2 个失败是 test_combined_writeback_keeps_the_admitted_lease_generation[False-file] 与 [False-sqlite]。它们在 main d33af49aa 上同样失败,根因是 Windows 上 --settlement-receipt 的 private capture 校验必然 fail-closed(见 #9398),与本 PR 无关。
未验证
test_task_lease_worktree.py在本机有 16 个用例因符号链接权限 / POSIX Git 被跳过。本 PR 改了该文件的时钟桩,但这些用例在 Windows 上没有被实际执行。task_lease_inspection.test.ts依赖的pg包本机未安装,未运行。- 没有做 POSIX 运行。
未决项
- 该 head 上没有完整的 Python 套件结果。 "Python Tests" run
45162874815的结论是 cancelled:6 个test-shard在 14:23:52 同时被取消,没有步骤记录,日志也未上传。我无法判断这是基建还是内容引起的;在套件于该 head 上跑完之前,我不给批准。 - 跨主机时钟差容差变小,请作者确认。 校验条件
updated > now与admittedAt > acquired里,租约侧时间原来截断到整秒,隐含吸收了最多约 1 秒的时钟差;本 PR 之后租约侧保留毫秒。租约写入方与 closeout 观察方不在同一台机器时(远端权威),这部分余量会消失,表现为 "clock is stale or ambiguous"。同机的 File/SQLite 不受影响。我没有验证这条路径是否支持远端权威,所以这是提问而不是缺陷认定;PR 描述目前没有提到这一点。
|
更正:写上一条复核时,本 PR 已合并 我上一条复核(11-24 14:09 UTC)是在本 PR 合并(11-23 14:23:46 UTC,合并提交
复核里其余内容不受影响,仍然适用:
合并提交 |
Recovery within one second
A prepared Turn can lose its lease and acquire a higher epoch in the same second. The admission receipt keeps fractional seconds, but the lease writer discarded them. A replacement acquired at 650 ms consequently appeared older than the receipt admitted at 250 ms. The administrative closeout rejected the original Turn even with the current writer’s exact proof.
The claim transport now supplies milliseconds. Acquisition, renewal, transfer and release retain the event time available from the native clock. The closeout transport supplies the observed time with microsecond precision. The existing verifier still checks the original identity, the replacement epoch and version, current ownership and temporal order. Expiry deadlines retain their existing whole-second representation.
Verification
The regression drives the public CLI against isolated File and SQLite providers. It admits a Turn at 250 ms, releases the lease at 450 ms, claims the replacement at 650 ms, renews at 725 ms and closes the original at 850 ms. Replay appends nothing, the Todo stays open and no quota is charged. Both providers reject a closeout observed before the renewal and a whole-second replacement whose order cannot be proven.
Before the change, both providers recorded the 650 ms acquisition at the start of the second. The lease and closeout suites passed after the change. This patch is independent of recovery action selection in #9304.