2c: 重订阅恢复(显式降水位:自报只允许向下修正) - #52
Merged
Merged
Conversation
POLICY-INVARIANTS:横切不变量 11(准入、显式降水位向下修正、图外标记、oracle-free/幂等、快照门禁不放宽)。 SEALING §2.3 补“自报只允许向下修正”例外;§3 事件/语义与破坏性/前向差异。
SyncManager:resetNamespaces(显式重置分区随 hello 以空时钟上报);recordPeerHello 自报只允许向下修正(作者缺失=0,绝不向上);快照“空水位”判据改为“每分区时钟均无计数”。 Mebular:rejoinNamespace(准入=生效授权(self) ∧ 成员在册;写图外 rejoin 标记;清本地水位)+ hasRejoinReset;初始化按标记恢复 reset 声明。 BREAKING CHANGE: 对端 hello 自报低于本机记录时下调本地水位(再订阅恢复)。
rejoin.test:清理后重入历史完整拉回、未授权显式失败、未 reset 不重发、重复幂等、无 tombstone/policy 保留、oracle-free。 namespace-watermarks:F3 改为“向下修正自动解污染 + reset 仍可显式修复”(断言收紧/更新,不削弱)。
onboard:rejoinNamespace/rejoinReset。cli:rejoin 子命令。 doctor:重入状态(reset 标记,恒 PASS 供审计)。
CLI:A/B 派活→A leave→A rejoin(reset)→再同步→A 历史拉回;B 不受影响;无 tombstone/policy 保留;未授权重入显式失败。all 114/114。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
2c · 重订阅恢复(显式降水位)
退订清理后重新加入:显式声明本机该分区已重置,使对端从 0 重新 offer、历史完整拉回。复用既有语义「对端自报水位只允许向下修正」,未新增同步协议、未放宽快照门禁(“自报分区水位为空”的判据改为“每个分区时钟均无作者计数”)、无 tombstone。
实现(R1–R5)
rejoinNamespace要求 ①getEffectiveNamespaces(self)含该分区(存在签发给本机的 grant;默认拒绝不变)②成员在册;任一不满足 → 显式失败not-authorized/membership-not-active。SyncManager.recordPeerHello起「自报只允许向下修正」——对端自报某作者计数低于本机记录时下调到自报值(作者缺失=0),绝不向上;下一次missingEventsForPeer即从修正后的水位重发(或按既有“空水位”门禁发初始快照,门禁不放宽)。重入方通过图外 reset 标记驱动buildLocalNamespaceClocks把该分区以空时钟随 hello 上报(普通空订阅不上报,避免无谓修正)。<storagePath>.rejoin.<ns>.json(图外、不同步、无 tombstone);Mebular.initialize依据它恢复 reset 声明。rejoin安全;rejoin/reset 不改变__policy__派生(签发者不变)。fleet rejoin --namespace <ns>;doctor增重入状态(reset=true/false)。主张 → 证据
2c ①(jest)+verify:fleet:rejoin(12→12)2c ②+ CLInot-authorized2c ③(B 署名事件,水位>0)2c ④__policy__保留2c ④/⑤+ CLI2c ⑥① B 数据不受影响 {"execB":3,"bTasks":12}verify:fleet:all114/114红 → 绿(断言原文)
buildLocalNamespaceClocks不含 resetNamespaces2c ③ 未 reset…reset 后才重发✕(reset 后未重发)→ 还原 ✓npm run build)if (reported < known)→if (false)verify:fleet:rejoin①FAIL A 历史完整拉回 {"before":12,"after":0}(10→9)→ 还原 10/10跨端 E2E 原始输出(
verify:fleet:rejoin,10/10)SEALING / 矩阵 diff 要点
POLICY-INVARIANTS.md:横切不变量 11(准入、显式降水位=自报只向下修正、图外 reset 标记、oracle-free/幂等、快照门禁不放宽)。SEALING.md§2.3:在「自报不抬升」后补 2c 例外——自报只允许向下修正;§3 新增重订阅恢复语义与破坏性/前向差异(旧节点无“向下修正” → 重入只可能少收,安全方向)。namespace-watermarks.test.ts的 F3 由「自报低不下降」改为「向下修正自动解污染 + reset 仍可显式修复」(断言更新/收紧,不削弱)。未做项 / 风险
fleet grant --to <rejoin设备>);否则显式not-authorized。resetPeerWatermarks部分冗余(hello 自报即可解污染);显式 reset 仍用于离线/尚未 hello 的场景。测试方式
npm ci && npm run build npm run test:coverage npm run verify:fleet:all node scripts/verify-fleet-rejoin.mjs