feat: support device init once and reinit#10
Merged
Conversation
zz-jason
reviewed
May 20, 2026
Contributor
zz-jason
left a comment
There was a problem hiding this comment.
按前面约定的 review 口径提交 inline comments:重点看了 init/reinit 状态机、proto 设计、脚本验证路径,以及是否有过度包装/可精简的重复实现。主要风险是通用初始化路径在“服务端已 init、但本地配置丢失/未落盘”时缺少恢复入口。
Contributor
Review summary这次按前面约定的口径看了 correctness、contract/proto、测试证明、脚本验证路径,以及是否有过度设计或可精简代码。 主要结论:
补充观察:SDK 的设备 init/reinit 路径没有被通用 |
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.
Context
data-platformnow treats device init and reinit as separate operations:InitDevice: first-time device provisioning only.ReinitDevice: refresh credentials/config for an already-initialized device.Related platform PR: archebase/data-platform#222
What Changed
DeviceInitService.ReinitDeviceto the SDK proto and regenerated Swift protobuf/gRPC bindings.ArchebaseDeviceInitializersoinitDeviceandreinitDevicecall distinct RPCs.saveConfigAndInit(configString:)still performs init-or-reinit, falling back toReinitDevicewhen the server reportsDATA_GATEWAY_DEVICE_ALREADY_INITIALIZED.Reviewer Follow-Up
ArchebaseDeviceInitializer.reinitDevicenow works even when the local config is missing, so callers have an explicit recovery path after remote init succeeds but local persistence does not complete.isReadyToUpload()requires a valid state whose endpoint hash matches the endpoint file, preventing stale credentials from being reported ready after partial local persistence failure.DGW_*_INIT_ENDPOINTvalidation toScripts/simulator_smoke.shlocal-mode execution and covered it with a script-shape test.xcuserdatascheme-order change and addedxcuserdata/to.gitignore.InitDeviceRequest/ReinitDeviceRequestas-is in this PR because changing that proto surface must be synchronized withdata-platform; this is not safe to do SDK-only.Validation
Latest reviewer-fix validation on commit
b47add7:bash -n Scripts/simulator_smoke.shswift test --filter DeviceInitializerTests:6 tests passedswift test --filter QiongcheDataGatewaySDKTests:32 tests passedswift test --filter LocalStackHarnessTests/simulatorSmokeScriptSkipsPackageUpdatesForCachedDependencies:1 test passedgit diff --checkswift test:222 tests passed; real/local gated integration tests skipped without their envEarlier ACK validation for this branch before the reviewer follow-up:
.local/e2e/sdk-ack-20260520-4d6c8bc-203555/swift-direct-realoss.log.local/e2e/sdk-ack-20260520-4d6c8bc-203555/swift-public-path-realoss.log.local/e2e/sdk-ack-20260520-4d6c8bc-203555/simulator-smoke-realoss.logRisks and Rollout
ReinitDevicecalls require the companiondata-platformserver rollout; deploy after archebase/data-platform#222.initDeviceremains create-only, whilereinitDeviceis the explicit recovery/rotation path.Checklist