Skip to content

Roll back both archive-managed runtime launchers - #9007

Open
loopx-agent wants to merge 7 commits into
mainfrom
codex/c1-paired-runtime-rollback-20261118
Open

loopx-agent wants to merge 7 commits into
mainfrom
codex/c1-paired-runtime-rollback-20261118

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

On POSIX archive installations, loopx update --rollback can leave the CLI
and archive-managed loopx-apply-rrule on different releases. Recovery must
also handle SIGINT immediately after either rename and preserve a helper that
another program replaces between the two renames.
SIGINT finding
Competing replacement finding

Behavior

  • Under the existing installer lock, validate the selected authority route
    and stage both managed launchers. Record the staged inodes before moving
    either link. Require an executable helper when the archive owns it.
  • Record each destination's original inode and check it again immediately
    before replacing that entry. Stop on an intervening change, including a
    new symlink with the same target. Restore entries still owned by this
    rollback after an interrupted or failed switch or failed core Doctor.
  • Preserve the single-launcher path for an absent or independently managed
    helper. A failed extension Doctor leaves the selected release active for
    provider repair.

Verification

  • File and SQLite independently exercised a separate process replacing the
    helper after the real CLI rename. The previous head overwrote that helper.
    This head stops before its helper rename, restores the CLI, preserves the
    independent process's exact helper inode and retains the Todo and provider
    revision. Both a new target and a different inode with the same target are
    covered. An ordinary paired rollback runs both real Doctors.
  • The two new regression tests failed before the fix. The focused suite also
    exercises SIGINT immediately after each rename, the absent primary, the
    independently managed helper, and distinct Doctor outcomes. At
    26aedee3d4, 109 tests passed and 3 Windows-only tests were skipped. Ruff,
    mypy and the RFC diff check passed.
  • The same exact candidate archive also recovered an admitted C1 Turn on
    File before writeback and on SQLite after writeback before accounting.
    Both restored the original capture and Todo and accounted once after retry.
  • Standard local premerge passed for this head against main@7bc56e7468 with 6 direct checks and 19 selected checks.
  • File and SQLite also committed the Turn before losing the CLI reply
    through a closed pipe. After rollback the earlier compatible build returned
    the three original receipts and preserved the exact writeback and single-slot
    records. Resubmitting a different slot count or spend source was refused.

The comparison exercises disposable macOS archive installations with provider
formats already current. Desktop rollback and migration across authority
formats have separate acceptance checks. #8966 still overlaps in
loopx/self_update.py.

Recovery-time launcher ownership

Current head 52efe8d25124 is based on main 45c015ffd9c9. Recovery checks the destination inode again after staging its restore link. If another process has published a new link in that interval, recovery leaves that link in place and restores the other launcher when it still owns that write. Recovery review

  • File and SQLite, with a controlled core Doctor failure and a separate process replacing the helper. The previous head's archive lost the other process's inode in all four competing cases. The exact candidate source preserved all four, including equal symlink targets, and restored the original CLI plus the same Todo and provider revision. Recovery without competition also passed on both backends.
  • The two rollback/installer suites and three release/update suites passed 209 tests with 3 platform skips. The standard premerge check has one failed local-install smoke. The same installed-skill assertion fails on the current main base.
  • The public archive default-contract check is held on both base and candidate by the existing C1 single-session outcome, complete-cost, and supported-profile requirements. Candidate recovery was exercised from the exact source revision against the same earlier packaged rollback target.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

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 · reasoning_effort=max

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

[P2] 第二条 symlink 替换成功后立即收到 SIGINT,会漏掉它的恢复。 我让 os.replace 完成助手的真实 rename,随后立即注入 SIGINT。恢复只查到已经登记的主 CLI。退出后主 CLI 指向原 release,助手仍从目标 release 启动,两个 Doctor 都未执行。请在 rename 前登记暂存 inode,并沿用当前的 inode 匹配恢复。替换与登记

动机 / Motivation

通过归档安装 LoopX 的用户执行旧版回退后,主 CLI 和调度助手需要指向同一个发行目录。正常回退时基线只替换主 CLI,调度助手仍停在旧目录。候选的正常路径切换两个入口。File 和 SQLite 实测均保留原 Todo 并成对切换,第二次替换成功后立即中断却仍可能留下不同版本。本次覆盖 POSIX 归档回退与现有两种 Doctor。Desktop 和跨格式升级沿原交付验证。

改动思路 / Approach

沿用原归档安装锁,在同一目录暂存两个 symlink,以 inode 确认识别回退操作的写入。本次范围为成对切换和可恢复写入。正常完成、替换前失败、core Doctor 失败和 extension Doctor 失败都通过同一归档入口。中断可落在第二次写入成功和登记之间,需要让已经写入的 inode 进入既有恢复条件。恢复循环

具体改动 / Changes

精确 head e556a651fa868c96d43ad4bf510be7332af8d700,base 02e3c5b64c55c90ac78d198bd89af87f7f386e64。3 个文件 +193/-46。按原发布规范核验 managed-pair-switch 和 restore-owned-pair-on-interruption。回退规范

关键代码讲解

  • 只处理 archive 管理的助手。File 和 SQLite 的真实权威读回都保留原 Todo 和 provider revision。基线正常回退只切主 CLI,候选成对切换。目标缺助手时保留两个原 inode。归属判定
  • 第二条 rename 前返回 OSError 时,会恢复主 CLI。core Doctor 失败时恢复两个入口,extension Doctor 失败时两个入口留在目标版供后续修复。包含原更新锁的并发测试通过。阶段处理 并发锁
  • 第二条 rename 成功时,信号可在 promoted 登记前进入恢复。实测主 CLI 恢复,助手仍为目标版。既有中断测试在 Doctor 才触发,覆盖的是登记完成后的状态。发生窗口 既有测试

对主干的风险 / Risks

76 项 Python 通过,3 项 Windows 跳过,标准本地预检通过 6 项直接、19 项所选检查。独立对照使用真实 POSIX symlink 和 File/SQLite 权威 CLI,Doctor 由隔离的可执行替身提供退出结果。Desktop、Windows 和跨格式升级沿各自交付资格验证。

语义与 CI 对齐

成对切换的正常路径复用原权威和安装锁。该锁约束其他更新进程,本进程仍可在两个步骤之间被信号中止。先记录暂存 inode 后,恢复仍可通过同 inode 条件保护后续独立写入。

我的整体评价 / Verdict

请求修改。正常回退和两类 Doctor 的决定已读回。第二次替换成功后的 SIGINT 仍会留下不同版本的入口,修复后应以同一真实 rename 和信号窗口复验。

English verdict: REQUEST_CHANGES. The second launcher can remain on the target archive after SIGINT lands between its real rename and ownership registration.

Comment thread loopx/self_update.py Outdated
for launcher in target_scripts:
staged = staging / launcher.name
staged_stat = staged.lstat()
os.replace(staged, launcher)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 在实际 rename 前记录暂存 inode。 真实第二次 rename 后注入 SIGINT,恢复只查到主 CLI,调度助手留在目标 release。请用现有 inode 校验恢复已写入的链接,同时保留独立 writer 的后续替换。

…-paired-runtime-rollback-20261118

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

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 · reasoning_effort=max

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

[P2] 第二次 rename 前复检 helper 的当前归属。 这里使用的是暂存时的观察。实际切换主 CLI 后,让独立程序替换尚未写过的 helper。下一次 rename 覆盖了较新的 inode,随后 SIGINT 使恢复写回早先捕获的链接。File 和 SQLite 都可复现。请在每个入口自己的 rename 前复检原观察,发现变化时中止并只恢复本次仍拥有的写入。 暂存和替换

动机 / Motivation

通过归档安装 LoopX 的用户回退时,需要让主 CLI 和调度助手一起切到兼容的版本。主干原路径只切换主 CLI。上一评审头已支持成对切换,但实际 rename 后收到 SIGINT 仍可能留下单边切换。本次候选在两次 rename 后的 SIGINT 都能恢复自身写入,也能正常重试。若独立程序在两次 rename 之间替换助手,本轮仍可能丢失这次较新的写入。独立复核限于 POSIX 归档回退、File 和 SQLite,以及两类 Doctor 的分支。

改动思路 / Approach

沿用安装锁,在写入前登记两个暂存 inode,并用当前 inode 核验每个入口的恢复归属。两个替换之间还需验证第二个入口原先的归属是否发生变化。本次范围为归档成对切换、已有任务可读及操作自有写入的恢复。另一个遵守安装锁的安装器会等待。回退仍需要防止独立程序改写受管理链接时被后一步覆盖。回退入口

具体改动 / Changes

评审 head 9dda43fae454b598685fba66b4fab627c0a12df8,diff base 1083771794744d663eb8c025788bd6c116f8c113,三文件 +218/-47。从上一头 e556a651 到本头核验了提前登记两个暂存 inode 的修正,并重审完整差异。验收覆盖 managed-pair-switch、restore-owned-pair-on-interruption 和 preserve-later-replacement。原发布约定

关键代码讲解

  • _managed_rollback_helper_target 从现有链接识别归档拥有的助手,_verify_rollback_todos 仍先确认原 Todo 可读。独立助手、原来没有助手、或归档缺目标助手三种路径均有真实链接读回。归属判定
  • execute_rollback_plan 在两次真实 rename 后分别注入 SIGINT。候选在 File 和 SQLite 均恢复两个原路径,首个中断保留未改助手的 inode,原来不存在的 CLI 恢复到不存在。重试成对切换,两类 Doctor 均运行。两次写入之后的独立替换也能按实际 inode 保留。登记与恢复
  • 两次写入之间替换助手时,候选覆盖新 inode,随后恢复到更早的助手。主干原路径在同一试验中保留独立替换。core Doctor 失败恢复成对路径并跳过 extension Doctor,后者单独失败则保留目标路径。恢复错误还会进入 Markdown 输出。失败与读回 回归套件

对主干的风险 / Risks

91 项 Python 测试通过,3 项 Windows 跳过。首次本地预检的安装 smoke 超时,构建通过校验的 Chat bundle 后原配置重跑通过 6 项直接与 19 项所选检查。独立对照实际执行 POSIX rename、信号和 File/SQLite 的 Todo 读回,两个 Doctor 通过受控可执行程序验证分流。另用 PyPI 正式 2.3.0 wheel 作为隔离目标,File 和 SQLite 均通过格式预检,随后因无法核验当前 Todo 被拒绝,两个当前 inode 未动。Desktop、Windows 和发布归档的跨版本资格另行验收。仍开放的同文件改动

语义与 CI 对齐

安装锁保护共用同一锁的写入者。恢复时匹配已安装 inode 的策略可保留之后的外部替换。第二次写入也需检查暂存以来发生的变化,才能保留当前归属。

我的整体评价 / Verdict

请求修改。上一评审的两个实际中断点已可恢复,File 和 SQLite 的原 Todo 及其版本也保留。补齐第二次写入前的归属检查,用另一程序在两次 rename 之间换链接的原反例复验。

English verdict: REQUEST_CHANGES. Both post-rename SIGINT windows now recover, but an independent helper replacement between the two writes is still overwritten and lost during recovery.

Comment thread loopx/self_update.py
staged_launchers[launcher] = staged.lstat()
# A signal can arrive immediately after the rename. Record ownership first.
for launcher in staged_launchers:
os.replace(staging / launcher.name, launcher)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 第二次 rename 前复检 helper 的当前归属。 这里使用的是暂存时的观察。实际切换主 CLI 后,让独立程序替换尚未写过的 helper。下一次 rename 覆盖了较新的 inode,随后 SIGINT 使恢复写回早先捕获的链接。File 和 SQLite 都可复现。请在每个入口自己的 rename 前复检原观察,发现变化时中止并只恢复本次仍拥有的写入。

…-paired-runtime-rollback-20261118

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

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 · reasoning_effort=max

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

动机 / Motivation

归档安装用户回退时,主 CLI 和调度助手要一起切换。中断或诊断失败后,回退应当只恢复自己仍拥有的入口。上一轮复现了助手在两次正向替换之间被外部进程更新后丢失。本次精确头加入 inode 校验,已通过原反例和同目标新 inode 的对照。新反例出现在失败恢复阶段。恢复旧助手的链接已经暂存时,独立写入仍会被后续 rename 覆盖。本轮复核范围是 POSIX 归档回退与 File/SQLite 权威 Todo 的可读性。

改动思路 / Approach

归档安装锁已经覆盖 Todo 验证、两次写入和恢复。正向发布前分别核对暂存时观察到的入口身份,失败时用已登记的目标 inode 判断恢复归属。产品边界是已有归档入口成对切换与兼容读取,不需要增加发布机制。在 File 和 SQLite 沙箱中,通过独立进程执行助手替换,用真实 symlink、rename 和 SIGINT 观察身份及重试。

具体改动 / Changes

精确 head 26aedee3d4624d1fdf2ebbcba91ba5e388b44329,diff base 7bc56e74687a93ff4d5bcccb532c454bf2379c29,3 个文件 +294/-48。逐项复核 switch-compatible-pair、stop-on-forward-replacement、restore-only-still-owned。验收约定

关键代码讲解

  • 选定版本先读取当前 Todo。File 与 SQLite 实测回退前后的 Todo 和 provider revision 一致。源码
  • 两次正向替换之间插入独立进程。同目标链接换 inode 和不同目标两个反例均会中止,恢复主 CLI 并保留独立写入的助手。源码
  • 恢复分支先读取目标 inode,随后创建旧链接再执行 rename。独立进程在旧链接已暂存时替换助手,随后仍被覆盖。File 与 SQLite 均复现。源码
  • 核心 Doctor 失败时恢复自有链接,扩展 Doctor 失败时保留已切换的可修复版本。两次真实 rename 后触发 SIGINT 均能恢复并成功重试。源码

对主干的风险 / Risks

恢复时丢失晚到的助手写入,后续调度可能使用旧版本。117 项 Python 测试通过、3 项跳过,标准预检通过 6 项直接检查和 19 项选中检查。竞态实验使用临时目录和受控 Doctor 进程。本轮未独立复跑作者的已接纳 Turn 归档回退、丢失 CLI 回复、Desktop、Windows 或权威存储格式迁移。

语义与 CI 对齐

正向替换按当前入口的 inode 校验,失败恢复也应在暂存旧链接之后确认仍持有将被覆盖的入口。现有锁继续串行化常规安装器。

我的整体评价 / Verdict

请求修改。原两类中断及正向独立替换已复验通过。请在恢复提交前再次确认当前入口归属,并将恢复暂存期间的独立替换加入 File 和 SQLite 回归测试,核对独立更新的 inode。

English verdict: REQUEST_CHANGES. The former forward-replacement and SIGINT findings are fixed. Failed-core recovery still overwrites an independently replaced helper after staging the restoration link.

Comment thread loopx/self_update.py
if previous is not None:
staged = Path(temporary.name) / launcher.name
staged.symlink_to(previous)
os.replace(staged, launcher)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 请在恢复暂存链接后再次核对目标 inode。File 和 SQLite 上,核心 Doctor 失败后,回退先读到自己发布的助手 inode 并暂存旧链接。此时独立进程原子替换现行助手,随后这次 rename 又覆盖了较新的 inode。请将第二次归属校验放在恢复写入前,并补上这个恢复窗口的测试。

…-paired-runtime-rollback-20261118

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

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, max)

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

使用 POSIX 归档安装的用户通过 loopx update --rollback 回退主 CLI 及由同一归档管理的调度助手。基线只切主 CLI。前一版已经成对切换并保护正向写入,但核心 Doctor 失败后,准备恢复链接期间出现的独立替换还会被覆盖。当前版本在暂存旧链接后再次检查目标 inode。检测到新 inode 时保留助手,同时恢复仍由本次操作持有的主 CLI 和原权威状态读回。这次交付覆盖 POSIX 归档路径和当前 File/SQLite 权威格式。

改动思路 / Approach

复用现有 installer promotion lock、权威 Todo 读回和 Doctor。先保存两条暂存链接的 inode,写入前核对目标,失败恢复时在准备旧链接后再核对一次。归档拥有的助手才参加成对切换。核心 Doctor 失败恢复自有入口,扩展 Doctor 失败保留当前发布的可修复版本。既有恢复评审中的时序已用同条件对照重跑。

具体改动 / Changes

精确 head 52efe8d251249df82c54434d3ff32ab95492fe03,diff base 45c015ffd9c9065b3af533e0abf103170627d15f,3 个文件 +319/-48。逐项复核 compatible-pair、restore-ownership、authority-and-retry、independent-helpers-and-extension。验收约定

关键代码讲解

  • 回退仍在 promotion lock 内先核验目标版本的权威 Todo 读取。普通成对回退跑完两层 Doctor,独立助手的 inode 在对照中保留。源码
  • 正向替换前核原 inode。恢复准备好旧链接后再核已发布的 inode,同目标但不同 inode 也保留。File 和 SQLite 的四个恢复对照都恢复了原 CLI 并保留更新后的助手。源码
  • 两次入口替换后的 SIGINT 均恢复原入口,重试可以完成。核心 Doctor 和扩展 Doctor 的失败继续走各自的恢复路径。源码

对主干的风险 / Risks

恢复时沿用现有 promotion lock。归属校验与 rename 仍是两次文件系统操作。本轮覆盖暂存期间的独立替换、正常回退和 SIGINT 后的恢复与重试。原 CLI 与 File/SQLite 的 Todo、provider revision 均有读回。

语义与 CI 对齐

匹配套件基线 180 项、当前 197 项通过,两版各 3 项平台跳过。独立回退对照保留了不同目标与同目标的新 inode。全库 Ruff、mypy 和公开 archive default 资格门在两版均有同一失败。独立临时 HOME 的安装 smoke 在两版都停在同一已安装 skill 断言。

我的整体评价 / Verdict

同意当前提交。恢复暂存期间出现的新助手 inode 已被保留,正常恢复与 SIGINT 重试均有实测。公开归档资格仍由 C1 的对应验收决定。

English verdict: APPROVE. The exact head preserves the newer helper inode observed during recovery staging and restores the original CLI on File and SQLite. Matched no-competition and interruption controls pass. The public archive qualification hold is unchanged.

This branch has not been deployed

No deployments
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.

1 participant