Skip to content

feat: complete SharpLink 0.7.x topology and resiliency#9

Merged
SunSi12138 merged 38 commits into
devfrom
feature/sharplink-075
Jul 22, 2026
Merged

feat: complete SharpLink 0.7.x topology and resiliency#9
SunSi12138 merged 38 commits into
devfrom
feature/sharplink-075

Conversation

@SunSi12138

Copy link
Copy Markdown
Owner

Summary

  • add static endpoint clusters, built-in load balancing, and endpoint-aware transports
  • add resolver-backed dynamic topology and DNS discovery
  • add idempotent unary retry, endpoint admission, and generation-scoped circuit breaker
  • add telemetry, documentation, local performance evidence, PackageSmoke, and NativeAOT coverage

Validation

  • Release build: 0 warnings / 0 errors
  • Unit tests: 257 passed
  • Integration tests: 195 passed
  • Generator tests: 43 passed
  • PackageSmoke and macOS arm64 NativeAOT passed
  • static and dynamic endpoint smoke matrices: 16 cases each, zero failures

Local development only; no release, tag, or merge is included.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

connection = await GetReadyConnectionAsync(
waitForReady: true,
control.Deadline,
cancellationToken).ConfigureAwait(false);

P2 Badge Pass admission context for wait-for-ready streams

For client-streaming calls with WaitForReady = true, this overload omits the method and outcome arguments, so endpoint admission/circuit breaker checks are bypassed before the stream is sent and the attached outcome has no acquired lease to report. The non-wait branch and the other call kinds pass that context into GetReadyConnectionAsync, so this only affects wait-for-ready client-streaming calls.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/SharpLink.Client/SharpLinkClient.StaticCluster.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.DynamicCluster.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.Invokers.cs Outdated
Comment thread src/SharpLink.Client/SharpClientBuilder.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.Attempts.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.Retry.cs
Comment thread src/SharpLink.Client/SharpLinkClient.Retry.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.StaticCluster.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.DynamicCluster.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.StaticCluster.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.Invokers.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.Retry.cs
Comment thread src/SharpLink.Client/SharpLinkCircuitBreaker.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.DynamicCluster.cs
Comment thread src/SharpLink.Client/SharpLinkClient.Retry.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.DynamicCluster.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkTransportFactories.cs Outdated
@SunSi12138

Copy link
Copy Markdown
Owner Author

Round 1 review completed for 66427f532d9b159f87ac04a877cfa28ce25c0281.

I left 8 inline findings: 6 correctness/concurrency issues and 2 lifecycle/TLS robustness issues. Local validation also passed all 495 tests (0 failed, 0 skipped), and the PR Quick check is green, so the findings are concentrated in adversarial cancellation, admission, half-open concurrency, ownership, and cleanup paths that the current suite does not exercise.

Non-blocking implementation/testing suggestions:

  • Add a table-driven admission test matrix covering unary, one-way, client-streaming, server-streaming, and duplex calls with both WaitForReady values, then combine the unary cases with retry and pending-table exhaustion. This would make “every acquired token is reported exactly once” an executable invariant instead of checking call shapes individually.
  • sharplink.client.breaker.open is currently incremented for every rejection while the circuit is open. Consider recording actual state transitions under that name, or rename the current counter to breaker.rejections; otherwise dashboards will overcount circuit-open events during long outages.

I will check the next head commit and re-review both these items and the rest of the repository.

@SunSi12138

Copy link
Copy Markdown
Owner Author

@codex review

Addressed the first-round topology, admission, half-open breaker, cleanup, and TLS findings in 3fd51bd. Validation: Release build (0 warnings) and 498 tests passed.

Comment thread src/SharpLink.Client/SharpLinkClient.cs Outdated
Comment thread src/SharpLink.Client/SharpClientBuilder.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.StaticCluster.cs
@SunSi12138

Copy link
Copy Markdown
Owner Author

@codex 请基于最新提交 0f9dffa 严格复审。

已修复:

  • 空动态拓扑下重复 ConnectAsync 不再等待恢复;
  • 响应反序列化先完成、失败以 RemoteError/DataLoss 上报准入策略;
  • 重试和等待就绪准入的超大延迟不再进行可能溢出的时间相加。

验证:Release 构建通过,完整测试套件 533/533 通过。

@SunSi12138

Copy link
Copy Markdown
Owner Author

@codex review

请严格复审最新提交 559a320。除已修复的动态空拓扑、响应解码准入结果、截止时间溢出外,本轮补齐了 0.7.9 的 endpoint/resolver/连接排空低基数 telemetry、生命周期收敛和主架构文档,并加入指标回归测试。

验证:Release 构建通过;完整测试 534/534;PackageSmoke 通过;macOS arm64 独立进程 NativeAOT smoke 通过。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 559a320280

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/SharpLink.Client/SharpLinkClient.DynamicCluster.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.StaticCluster.cs
@SunSi12138

Copy link
Copy Markdown
Owner Author

@codex review

已修复本轮两项反馈:

  • 解析成功后发生的端点连接失败不再错误计入 resolver failures;无效快照也只计一次。
  • 客户端端点与连接状态指标改为可观测的当前总量,避免在监控监听器后接入时产生无对应的负值。

验证:Release 构建通过;全量测试 534/534 通过;包引用冒烟测试和独立进程 shared-memory AOT 冒烟测试均通过。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 053b5fecf5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/SharpLink.Client/SharpLinkClient.Retry.cs Outdated
@SunSi12138

Copy link
Copy Markdown
Owner Author

@codex review

已修复 P2:客户端停止会取消自定义重试退避、重试路径准入 RetryAfter,以及普通 WaitForReady 准入 RetryAfter;调用立即以 ConnectionClosed 结束。

新增三项覆盖测试。验证:Release 构建通过;完整测试 537/537 通过;本地 NuGet PackageSmoke 与 macOS arm64 独立进程 shared-memory AOT 冒烟通过。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71f885077f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/SharpLink.Client/SharpLinkClient.CallOptions.cs
Comment thread src/SharpLink.Client/SharpLinkClient.DynamicCluster.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClusterOptions.cs Outdated
@SunSi12138

Copy link
Copy Markdown
Owner Author

@codex review

已修复本轮三项 P2:

  • 超大 retry/admission delay 以可取消的安全分段等待处理,不再触发 Task.Delay 范围异常。
  • 动态拓扑首次拨号失败后,重复 ConnectAsync 会等待后台恢复,不再重放旧失败。
  • 静态拓扑的 MinReadyEndpoints 校验改为与端点数量封顶后的实际目标比较。

验证:Release 构建通过;完整测试 537/537 通过;本地 NuGet PackageSmoke 与 macOS arm64 独立进程 shared-memory AOT 冒烟通过。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f20e9881d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/SharpLink.Client/SharpLinkClusterOptions.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.Retry.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.DynamicCluster.cs Outdated
@SunSi12138

Copy link
Copy Markdown
Owner Author

@codex review

已修复本轮三项 P2:

  • 动态 resolver 的有效 MinReady 按 MaxEndpoints 上限校验。
  • 内置 retry 的巨大 jitter delay 在转换 ticks 前钳位,继续进入可取消分段等待。
  • resolver 从初始失败恢复为已接受空拓扑时,会释放等待中的 ConnectAsync。

验证:Release 构建通过;完整测试 540/540 通过;本地 NuGet PackageSmoke 与 macOS arm64 独立进程 shared-memory AOT 冒烟通过。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e67a08ef7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/SharpLink.Client/SharpLinkCircuitBreaker.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.DynamicCluster.cs
Comment thread src/SharpLink.Client/SharpClientBuilder.cs
@SunSi12138

Copy link
Copy Markdown
Owner Author

@codex review

已修复本轮三项 P2:

  • 熔断器仅将端点/传输类 SendFailure 计为失败,忽略本地序列化与校验错误。
  • 静态与动态集群在连接完成握手后被拓扑/停止门拒绝时,会释放已创建的 ClientConnection。
  • 静态与动态端点集群均拒绝一次性匿名管道工厂。

验证:Release 构建通过;完整测试 543/543 通过;本地 NuGet PackageSmoke 与 macOS arm64 独立进程 shared-memory AOT 冒烟通过。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bcccdc1023

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/SharpLink.Client/SharpLinkClient.DynamicCluster.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.DynamicCluster.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.StaticCluster.cs Outdated
Comment thread src/SharpLink.Client/SharpClientBuilder.cs Outdated
@SunSi12138

Copy link
Copy Markdown
Owner Author

@codex review

已修复本轮 3 项 P2 与 1 项 P3:

  • 初始 ConnectAsync 在替换拓扑已就绪时立即完成,不再等待退休的慢拨号。
  • 已退休但仍在拨号的端点继续占用全局 Ready+Connecting 预算。
  • 静态和动态端点池在采样到陈旧连接时,会回退到同端点可接收调用的连接。
  • 端点工厂性能配置绑定失败时会释放该工厂。

验证:Release 构建通过;完整测试 547/547;本地 NuGet PackageSmoke 与 macOS arm64 独立进程 shared-memory AOT 冒烟通过。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8bee284670

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/SharpLink.Client/SharpLinkClient.StaticCluster.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.DynamicCluster.cs Outdated
Comment thread src/SharpLink.Client/SharpLinkClient.Attempts.cs Outdated
Comment thread eng/run-v075-static-performance-matrix.sh Outdated
@SunSi12138

Copy link
Copy Markdown
Owner Author

@codex review

已处理本轮 3 项 P2 与 1 项 P3:

  • 静态和动态集群的初始拨号改为滑动补位;一个快速失败不会再被同批慢拨号阻塞,后续健康端点会立即被探测。
  • 准入 RetryAfter 按当前选择内的决定顺序判断:陈旧授予不再掩盖其后的拒绝延迟,同时保留“授予覆盖更早拒绝”的既有语义。
  • JIT-only 性能矩阵不再依赖 NativeAOT RID 探测。

新增静态/动态慢同级拨号回归与准入顺序回归。验证:Release 构建零警告;完整测试 550/550;性能矩阵脚本语法检查通过。

Repository owner deleted a comment from chatgpt-codex-connector Bot Jul 22, 2026
@SunSi12138

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 139759bfca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SunSi12138
SunSi12138 merged commit bfb26f0 into dev Jul 22, 2026
1 check passed
@SunSi12138
SunSi12138 deleted the feature/sharplink-075 branch July 22, 2026 09:06
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