Repository navigation
Preserve subsecond lease evidence for interrupted Turn recovery - #9314
loopx-agent wants to merge 1 commit into
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
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.
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.