Repository navigation
feat: add peer generation synchronization - #718
SunSi12138 wants to merge 1 commit into
Conversation
a558c0e to
58c18cb
Compare
|
Squashed the implementation to one focused commit without changing the final tree.
Final-head CI is being rerun now. After the core checks pass, PR Extended will be triggered on this exact head. |
|
Final development verification completed on focused head Self-review pass 1 — engineering boundaries:
Self-review pass 2 — #691 refined acceptance:
Final-head CI:
The PR description has been updated from the earlier query/watch wording to the final duplex API. No merge action has been taken. |
SunSi12138
left a comment
There was a problem hiding this comment.
审核结论:当前有 1 个需要修改的 correctness / reconnect 语义问题,暂不通过。
整体方向符合 #691 最新设计:远端 surface 只有 declaration/query + Client-initiated duplex sync,本地 provider 才拥有 Stage/Validate/Activate/Drain;没有重新引入 #717 的 remote-mutation 模型。包依赖边界、public API/package smoke、NativeAOT 边界也都合理。
阻塞点是 inventory revision 的重启/切换语义:当前公开 API 只给出 endpoint-local monotonic Revision,但文档同时要求 process restart / reconnect 后重新发送完整 snapshot 并自然收敛。API 中没有 endpoint epoch / instance identity,也没有规定新 stream 的首个 snapshot 必须无条件覆盖旧 revision。如果 revision 在进程重启后重置(或重连到另一个 endpoint),消费者按常见的 revision <= lastRevision 去重就会把新的真实状态持续当成 stale。
建议在 public API 首次发布前明确一种可执行语义,例如:
- 增加 endpoint epoch / instance id,并把顺序定义为同一 epoch 内比较 revision;或
- 明确 revision 只在单次 sync stream 内可比较,每个新 stream 的首个完整 inventory 必须无条件接受,同时说明
GetInventoryAsync响应不能用历史 revision 跨连接判 stale。
当前 head 的 PR Fast、PR Package Smoke、CodeQL、Codec Padding Security Evidence、PR Extended 均为 success;这个问题是 API 语义缺口,不是 CI 失败。
不合并、不修改 #691 状态。等待作者修正后再复审。
063c054 to
d8fc5db
Compare
d8fc5db to
1743169
Compare
|
Addressed the blocking reconnect/restart review finding on final head Root cause:
Change:
CI failure/fix:
Final verification:
The PR remains one focused commit directly on current |
Background
Issue #691 was refined from a remote-control model to peer declaration + local reconciliation.
Either Client or Server may change generation first. The changed endpoint declares its current generation/compatibility state; the peer observes that state and decides locally whether it needs to follow.
Core rule:
This PR supersedes the closed #717 design. It intentionally removes #717's remote Stage/Activate RPC surface.
Transport model
SharpLink v2 RPC requests are Client-initiated, so the implementation does not pretend that Server can open an RPC back to Client.
The stable remote contract is declaration-only:
GetInventoryAsync: Client queries the Server's current complete generation inventory.SynchronizeAsync(clientInventories, ...): Client opens a duplex stream.This supports both Server-first and Client-first generation changes without adding Server-initiated RPC or remote mutation commands.
Inventory ordering / reconnect semantics
Each
SharpLinkGenerationInventorycarries:EndpointEpoch: opaque ordering scope for the endpoint's declaration sequenceRevision: monotonic only within that epochRules:
EndpointEpochis equalGetInventoryAsyncand duplex synchronization use the same rule; historical revisions from another epoch must never make a current response look staleOn reconnect/restart, each side publishes its current complete inventory again. Correctness does not depend on event replay.
Local-only reconciliation
StageAsync,ValidateAsync,ActivateAsync, andDrainAsyncexist only on localISharpLinkGenerationProvider.Peer metadata is input to local policy; it is never an instruction to execute/load an artifact or replace a process.
NativeAOT remains explicit through local
ProcessReplacementRequiredoutcomes.Package / CI integration
SharpLink.GenerationControlpackageSharpLink.Abstractions; Generator remains analyzer-onlyGetInventoryAsyncandSynchronizeAsyncEndpointEpochsurvives query and duplex serializationNon-goals
The package does not:
Review fix
The blocking reconnect/restart review finding is addressed by introducing
EndpointEpochas the revision ordering scope and documenting the acceptance rule for a changed epoch across both query and duplex paths.Fixes #691