Skip to content

fix(coordination): order the lease inventory by member name - #8762

Merged
loopx-agent merged 1 commit into
loopx-project:mainfrom
BigDataDZ:codex/source-lease-inventory-order-20261114
Nov 14, 2026
Merged

loopx-agent merged 1 commit into
loopx-project:mainfrom
BigDataDZ:codex/source-lease-inventory-order-20261114

Conversation

@BigDataDZ

Copy link
Copy Markdown
Contributor

Motivation / 动机

_source_lease_paths 用 sorted() 对 iterdir() 的 Path 排序。Path 比较在 Windows 上做大小写折叠(PurePath._str_normcase),在 POSIX 上不折叠,所以同一个 task-leases 目录在 Windows 上产出 todo_alpha.json 在 todo_Bravo.json 之前,POSIX 上相反。lease inventory 是 byte-stable source witness 的输入,其顺序不应依赖平台路径比较。

真实 Windows 上 tests/control_plane/test_shadow_registry_source.py::test_source_snapshot_preserves_inventory_without_projecting_orphan_leases 因此在未修改 main 上稳定失败(期望 POSIX 序,实得 Windows 序)。

Change / 变更

loopx/control_plane/coordination/authority_source_capture.py:按成员名字符串(ordinal)排序,替代 Path 序,两平台产出完全一致的 inventory 顺序。仅此一处,命名校验与其余守卫不变。

Validation / 验证

基于 main 1cdd9bbef,真实 Windows 运行:

sorted() over WindowsPath folds case, so the same task-leases directory
ordered todo_alpha.json before todo_Bravo.json on Windows and after it
on POSIX. The lease inventory feeds a byte-stable source witness, so
its order must not depend on the platform's path comparison. Sort by
the member name string instead.

Signed-off-by: BigDataDZ <[email protected]>
@BigDataDZ

Copy link
Copy Markdown
Contributor Author

windows-powershell 失败与本 PR 无关(跨 PR 既有故障,同 #8761)

本 PR 的 windows-powershell 与 #8761 挂在同一处:步骤 "Qualify the native Windows CLI output differential",base 侧 read_pinned_cli_body 抛 FileNotFoundError: [WinError 2]。同一签名在其他 PR(如 #8758)同样出现,失败点位于 pinned base 基线读取,不在本 PR 的 diff(lease inventory 排序)覆盖范围内。相关分析见 #8761 的评论。

@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

评审提交 4b00c5b,对应合并基点 1cdd9bb;当前目标 main 为 4604f93,相关采集、校验和 CLI 同路径未变。没有发现阻塞本次排序修复的问题。

动机 / Motivation

受影响的是在 Windows 上为旧 Goal 盘点留存租约或建立协调影子快照的操作者。目录同时有大写和小写名称时,采集器与最终校验器可能给同一批文件排出不同顺序。即使文件都没动,真实命令也会报来源已变,重试仍走同一个失败分支。修复后,两处按相同的文件名顺序核对每个文件及其摘要。范围是租约清单排序;Windows 时间戳读回的另一个缺口由 #8761 跟进。

改动思路 / Approach

继续让 Python 读取原文件,TypeScript 在现有锁内核验完整清单、成员身份和字节,再由原 owner 决定是否写入。只改已有采集点的比较键,没有新状态、接口或开关。保留逐项摘要比较;若在最后忽略数组顺序,便只在一个消费者掩盖差异,只读盘点仍会拿到平台特有的排序。当前交付边界是现有来源清单一致性,仍由原准入和持锁校验决定能否产生快照。

具体改动 / Changes

按主干的 docs/reference/reviewed-coordination-promotion.md(4604f938b612c5da0d8a3485ce563bea922fc14e)判断:完整租约清单在真实 CLI 中已读回;变化来源拒绝在改字节反例中仍成立;只读盘点无执行权保持成立。三种证据都分别核对了旧路径对照与候选。

关键代码讲解

  • _source_lease_paths 从 Path 对象的比较换成成员名字符串的顺序。这里允许的名字是 ASCII,因此同一组文件的顺序不再依赖平台或目录枚举次序。原名称、目录、链接和文件拒绝规则没有放宽。
  • _build_runtime_shadow_source_snapshot 给每个成员保留原字节摘要。没有对应当前 Todo 的留存租约仍在来源清单里,不会变成活动图中的边。
  • verifyShadowSourceSnapshot 保留现有的 ASCII 顺序、二次枚举和逐项校验。正常 macOS 对照中两版都可写入;只替换采集器的 Path 比较为 PureWindowsPath 比较后,基线返回 source_changed_retry,候选按 Bravo、Zulu、alpha 的顺序提交。三个原文件的字节不变。

对主干的风险 / Risks

在采集后给一份真实文件追加一个换行,候选仍拒绝,未发布影子快照;关闭写入开关时,两版都在采集前拒绝 bootstrap。另走不要求开启影子的 inspect-source,同一混合大小写输入基线误报变化,候选读回三份留存租约,未写影子状态、未报告可导入。底层获取锁可能创建锁目录;它不代表切换 authority。这里复用了现有词汇和来源校验,没有更改租约生命周期、默认权限或运维指令。

语义与 CI 对齐

真实本地 CLI 用实际文件和 TypeScript 写入边界,模拟的仅是 Windows 的 Path 比较。源码基线和候选各 26 项回归通过;Ruff、DCO、双语 RFC 差分和合并树检查通过。未独立运行原生 Windows/ACL,也未跑合并后的全平台矩阵。作者报告的 Windows 运行和其 CI 观察分别保留为作者证据。这轮没有查询托管 CI,也不把这个结论扩展到在两层同时出现的 ctime 差异。

我的整体评价 / Verdict

批准这个排序修复。操作者对同一份未变化的文件重复运行时可得到稳定结果,仍能区分真实变化和配置关闭,且不需要新设置、手工排序或放松校验。它解决的是可独立复现的顺序差异;后续仍需维持原生 Windows 检查,以及单独处理 #8761 的最终 ctime 校验。这里没有改变产品页面,也没有授予写入或合并权。

English verdict: APPROVE at 4b00c5b. The real CLI accepts the same mixed-case inventory under simulated Windows path ordering and still rejects changed bytes. Native Windows validation and the independent ctime fix remain separate.

@loopx-agent
loopx-agent merged commit b1725ae into loopx-project:main Nov 14, 2026
38 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