Repository navigation
refactor(harmony): drive the native round through the shared round engine - #677
Conversation
…gine SyncCoordinator.ts's hand-written round (runConfiguredRound, the endpoint query walk, the two-budget performAttempts loop, runWithinDeadline and the result mapping) becomes a loop over NativePatchCore.stepRound (new synchronous NAPI binding over flowcore::StepRoundJson) that runs the commands it returns: the breadcrumb, the launch env, HTTP, the installed check, downloads and the commit. HTTP and downloads stay asynchronous ArkTS; each engine step is a cheap synchronous call, so nothing blocks the single thread. The host's post-wait check compares configs by C1 equivalence (was string equality), matching Android and iOS. Tests: harmonySyncRound.test.ts replays the round-engine vectors against the adapter (the vectors' commands stand in for the engine, the IO answers come from the next vector event) and checks every event the adapter sends back plus the mapped result; it replaces the query-walk and attempt-loop tests of the deleted functions. nativeHostApi.test.ts drives the host API through a scripted engine instead of the removed functions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
…atforms Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RoundEngine 系列的最后一步:鸿蒙接入共享轮次引擎。本 PR 基于 #669 合入后的 master。
改了什么
NativePatchCore.stepRound(stateJson?, eventJson),同步调用flowcore::StepRoundJson。它经 fix(native): catch C++ exceptions at the HarmonyOS NAPI and iOS entry points #674 的Guarded<>导出,C++ 异常不会进 NAPI。SyncCoordinator.ts删掉了手写的runConfiguredRound、runQueryRequest、performAttempts、runWithinDeadline和结果映射。runOnce改为循环调用引擎,逐条执行它返回的命令:perform:处理 env、HTTP、checkInstalleddownload:用引擎给的 deadline 计时,超时回报 timedOut,失败回报错误码commit:提交finishRound:映射结果HostCancellation规则相同。SyncCoordinator.ts净删 78 行(+225 / −303)。测试
harmonySyncRound.test.ts。它把round-engine-vectors.json当作脚本化的引擎:向量里的命令代替引擎输出,IO 的结果取自向量的下一个事件。逐步核对适配器回给引擎的事件和最终映射结果,共回放 23 条轨迹。crash hold、forceActivate、轮次预算、下载超时这几类鸿蒙不会产生的轨迹,以及故意制造协议错误的轨迹,没有纳入。config_changed的分支,对应用例会失败。harmonySyncQuery、harmonySyncAttempts,它们测的函数已经删除。nativeHostApi.test.ts改为用按场景出命令的假引擎来驱动宿主 API。12 个用例的断言保持不变。bun test(456 个)、bun run lint(含 DevEco SDK 的鸿蒙类型检查)。pushy.cpp用 SDK 的 clang 编译通过。🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit