Repository navigation
fix(leases): fold Unicode normalization aliases in write-scope comparison - #9205
Jiaqiiii523 wants to merge 1 commit into
Conversation
…ison NFC and NFD spellings of one host path now overlap in the comparison view; stored scope and request spelling stay unchanged. Signed-off-by: Jiaqiiii523 <[email protected]>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
动机 / Motivation
为已有文件范围领取独占任务租约的操作者需要让旧 glob 和别名都继续受到冲突约束。 共享比较已处理大小写和路径词法别名,已有效的通配符和字符类会覆盖文件原拼写。 同一保留的分解字符路径,在主干原实现中同时匹配采用两个字符通配符或字符类加字面量的范围。准确头和当前主干整合预演中,这两种范围的租约重叠都从 true 变为 false;正反顺序一致。调度重叠和写入范围覆盖仍为 true。 提案在比较时加入 NFC,显式字面别名能冲突,实际租约比较却会漏掉已有 glob 命中。 实测源代码的共享 TypeScript 比较和 File/SQLite CLI 定向用例。反例是只读比较,没有执行实际并发写入。
改动思路 / Approach
继续由 TypeScript 范围比较拥有冲突判断。NFC 只用于比较,声明和请求身份的所有者保持独立。 独占租约冲突和工作区范围检查复用同一比较。调度和 Todo 声明覆盖也读取相关范围。 在既有 glob 比较保留原域,再补充规范等价命中。不会增加持久状态、请求身份或专用提供者。
具体改动 / Changes
逐项检查当前头 8a9a3c7 和 merge base de61cfe,4 个文件,+85/-4。只比较 NFC/NFD 的增量使用场景,同时逐项检查已有原始路径命中、独占判断、调度和覆盖。nfc-alias 的新增字面别名命中通过。retained-identity 的原拼写保留。glob-parity 未满足,覆盖投影与实际租约重叠不一致。File/SQLite 的普通别名与不同路径对照通过,整合预演没有消除反例。 评审依据为 8a9a3c7。 目标规范
关键代码讲解
- 比较折叠 在构造比较序列之前组合 Unicode 码点。
- glob 匹配 从组合后的候选序列消费字符,但模式里的通配符和字符类继续按原 token 工作。旧的分解字符匹配丢失。
- 冲突选择 同一个观察入口给现有 lease 比较使用。
对主干的风险 / Risks
[P2] NFC 折叠漏掉已有 glob 的范围重叠。 同一保留的分解字符路径,在主干原实现中同时匹配采用两个字符通配符或字符类加字面量的范围。准确头和当前主干整合预演中,这两种范围的租约重叠都从 true 变为 false;正反顺序一致。调度重叠和写入范围覆盖仍为 true。 在现有比较所有者中保留原 glob 命中,然后再补充 NFC 别名匹配。继续用原拼写入库,并为已有使用两个通配符和字符类的声明增加主干/新头的对照。 原有范围仍允许写同一文件时,独占冲突比较不能把两个重叠声明判为隔离。现有工作区范围检查也使用这条比较。
准确头和整合预演在两种显式 NFC/NFD 拼写上确认冲突,组成字符的单通配符对照仍命中,两条真正不同的路径仍判为不重叠。 准确头的 TypeScript 32 项通过、1 项环境跳过。定向 File/SQLite CLI 测试 70 passed, 130 deselected in 264.35s (0:04:24)。标准 quick premerge 通过。 实测源代码的共享 TypeScript 比较和 File/SQLite CLI 定向用例。反例是只读比较,没有执行实际并发写入。
我的整体评价 / Verdict
请求修改。继续由 TypeScript 范围比较拥有冲突判断。NFC 只用于比较,声明和请求身份的所有者保持独立。 独占租约冲突和工作区范围检查复用同一比较。调度和 Todo 声明覆盖也读取相关范围。 新的字面别名行为通过,旧有两类合法 glob 命中不再受到相同的独占冲突约束。 请在同一比较所有者补齐旧匹配的兼容性,并用同一输入核对租约重叠、调度和许可覆盖。 运行结果覆盖新旧范围;没有涉及图形操作。 独立验证范围为本地合成项目和对照结果。
English verdict: REQUEST_CHANGES at 8a9a3c7. NFC literal equivalents now conflict, but normalizing the input before consuming glob tokens loses previously matched decomposed paths. Scheduling and scope coverage still overlap while exclusive lease comparison does not.
| function caseFold(value: string): string { | ||
| let folded = ""; | ||
| for (const character of value) folded += foldCharacter(character); | ||
| for (const character of value.normalize("NFC")) folded += foldCharacter(character); |
There was a problem hiding this comment.
[P2] NFC 折叠漏掉已有 glob 的范围重叠。同一保留的分解字符路径,在主干原实现中同时匹配采用两个字符通配符或字符类加字面量的范围。准确头和当前主干整合预演中,这两种范围的租约重叠都从 true 变为 false;正反顺序一致。调度重叠和写入范围覆盖仍为 true。 在现有比较所有者中保留原 glob 命中,然后再补充 NFC 别名匹配。继续用原拼写入库,并为已有使用两个通配符和字符类的声明增加主干/新头的对照。
Goal And Delivered Outcome
NFC and NFD spellings of one path are the same host file on macOS, but the shared write-scope comparison only case-folded. Two agents could hold exclusive leases for
src/café.ts(NFC) andsrc/cafe\u0301.ts(NFD) while each believed it held exclusive authority.This change folds canonical Unicode normalization (NFC) in the comparison view. The stored scope spelling, the immutable request identity, the persisted canonical scope set and glob character-class bodies stay unchanged.
task-lease acquirefor the NFD spelling returnedexit 0,acquired: true, and both leases readactive; after the change it exits 1 withwrite_scope_conflictand provider state is unchanged.caseFoldnormalizes the full comparison value to NFC before the existing per-code-point case fold.comparisonWriteScopes,normalizeWriteScopes, persisted spelling and class bodies are untouched. The contract atdocs/reference/canonical-lease-renew.mdnow states the rule.Validation
src/Main.tsvssrc/main.ts->write_scope_conflict;src/café.tsvssrc/cafe\u0301.ts->write_scope_conflict; distinctsrc/cafe.tsvssrc/café.ts-> allowed.tests/control_plane/test_canonical_lease_scopes.py: 200 passed (File and SQLite; includes acquire, atomictodo claim, and the negative control).tests/control_plane_ts/task_lease_workspace.test.ts: 32 passed / 1 environment skip; the adjacent lease suites 81 passed / 1 skip.python -m mypy: 17 files, no issues.ruff checkon the changed files: clean.loopx check --scan-pathon the four files: clean.loopx canary premerge --git-diff-base de61cfe6a35 ...: 18 selected, 0 failures;self_merge_validation_passed: true.Scope And Continuation
src/[é]xmatches an NFD candidate; an NFD-authored class is intentionally out of this slice.de61cfe6a35; Recover the original Chat Todo and Monitor confirmations #8725 also touchestask_lease_acquire_decision.tsfor a separate**/glob change, and its equivalent**/work is already on main via fix(leases): treat a recursive glob segment as matching zero directories #8680, so only a textual rebase may be needed if it lands first.Type of Change
LoopX Area
Technical Direction
Core control-plane hardening.
Written by: model_agent (Qoder CLI). AI disclosure: drafted with AI assistance under the author's direction and review.