Repository navigation
refactor(apple): deslop shared Swift packages - #158509
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 26, 2026, 7:40 AM ET / 11:40 UTC (Revision 7). ClawSweeper reviewWhat this changesThe branch consolidates Swift code shared by the iOS and macOS apps for chat, Gateway connections, caches, credentials, and audio, while preserving message metadata and handling oversized tool-read ranges. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness⛔ Blocked before merge - 2 items remain Keep open. Current main retains the two source-proven defects addressed here, and no merged related PR replaces this shared-package work. Source review found no discrete new bug. Priority: P3 Review scores
Verification
How this fits togetherOpenClaw’s shared Swift packages turn Gateway events, device credentials, and locally queued commands into native app state. The iOS and macOS apps use that state to reconnect, send messages, and render conversations. flowchart LR
A[Gateway events] --> D[Shared Swift transport]
B[Device credentials] --> D
C[SQLite queued sends] --> D
D --> E[Chat message models]
E --> F[iOS and macOS chat views]
Before merge
Agent review detailsSecurityNone. PR surfaceOther -1088. Total -1088 across 70 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the shared Swift ownership cleanup and targeted fixes, with native reconnect evidence confirming the existing queued-send delivery contract before landing. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main reconstructs chat content without preview and runId and converts unbounded read-range values to Int. This read-only review did not run native code. Is this the best way to solve the issue? Yes for the two concrete defects: value-copy updates preserve growing message models, and checked integer conversion avoids a trap without changing valid range display. The queued-send refactor still needs delivery evidence. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a53efa5e7251. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
|
Shared-owner handoff from the iOS deslop sweep: the optional shared Periphery intersection reports The other three findings are redundant public accessibility on |
Consolidate shared chat, Gateway, cache, storage, and audio owners while preserving protocol, identity, persistence, and presentation contracts. Preserve preview and run metadata during message value updates, and avoid integer-conversion traps when displaying oversized tool read ranges.
Remove the external authorization sentinel and its unreachable branches and exclusive tests. The iOS Access drafts will restore it with their producers. Drop the watch status switch cleanup that exceeded the strict iOS SwiftLint complexity limit, retaining the pre-sweep implementation and tests.
e355a63 to
b013496
Compare
* refactor(apple): deslop shared Swift packages Consolidate shared chat, Gateway, cache, storage, and audio owners while preserving protocol, identity, persistence, and presentation contracts. Preserve preview and run metadata during message value updates, and avoid integer-conversion traps when displaying oversized tool read ranges. * refactor(apple): retire unproduced authorization prerequisite Remove the external authorization sentinel and its unreachable branches and exclusive tests. The iOS Access drafts will restore it with their producers. Drop the watch status switch cleanup that exceeded the strict iOS SwiftLint complexity limit, retaining the pre-sweep implementation and tests.
What Problem This Solves
Shared Apple packages repeat message reconstruction, Gateway error projection, WebView lifecycle handling, cache logic, and persistence plumbing. Field-by-field reconstruction also loses message metadata as the models grow.
User Impact
Reachable Gateway wire behavior, pairing/authentication, Keychain identifiers and access groups, permissions, defaults/state formats, rendered layout and strings, entitlements, bundle identifiers, updates, and URL schemes remain unchanged. No dependency or SwiftPM version changes.
Message normalization and canonical voice-note reconciliation retain previously dropped
previewandrunIdmetadata. Tool read summaries safely use the existing path-only display when numeric bounds cannot fit a Swift integer.Why This Change Was Made
Production code shrinks by 1,089 lines (+809 / -1,898), excluding Tests/ and generated sources. The sweep read the hand-written shared packages and their Apple callers; generated Gateway models remain unchanged.
Fixes found along the way
previewandrunIdduring normalization and local audio-duration preservation. Both strengthened regressions fail on the original history owner and pass on the candidate.WatchCommands.swiftretains its pre-sweep implementation and tests. No suppression or threshold change was added.Retired prerequisite
Retire
GatewayExternalAuthorizationError, its unreachable admission/reconnect and connection-problem branches, andexternalAuthorizationRequired, introduced by #157454. No production target on main constructs the type; only its dedicated tests did. This matches the deletion in #157413. Per the explicit maintainer decision, the iOS Access drafts #147238 and #147244 will restore it alongside their producers.Remove the two tests (three executions) that exclusively constructed the retired type. Existing
connect entry points preserve upgrade provider errorscoverage retains typed propagation through connect/request/send. Transient reconnect, cancellation, and custom-header safety tests remain unchanged. No reachable authentication or permission behavior changes.Evidence
Local Apple commands ran serially at
nice -n 10; no full native app suite or unsigned app was launched on the operator desktop. Full native suites run in disposable hosted CI. TypeScript verification uses Blacksmith Testbox.swift build --build-system native --build-tests --disable-index-store -Xswiftc -gline-tables-only --jobs 4: passed; final incremental build 45.34s after the watch-hunk withdrawal.swift build --build-system native --product OpenClaw: passed, final 41.26s compiler / 43.60s wall.swift build --build-system native --build-tests: passed, final 31.29s / 33.25s. Both used jobs 4 and disabled the index store.xcodebuild -project apps/ios/OpenClaw.xcodeproj -scheme OpenClaw -destination 'generic/platform=iOS Simulator' -configuration Debug -jobs 4 ARCHS=arm64 ONLY_ACTIVE_ARCH=YES CODE_SIGNING_ALLOWED=NO build: passed, 271.256s build / 285.49s wall. SwiftFormat passed and SwiftLint reported zero violations across 422 files.The first final-tree Testbox attempt verified source tree
e5eb41fe0a4362e0a937b75ed92934d25783f905and localization, then ended with exit 255 before a completion record. Its capture contains no reported assertion failure; it is not counted as a passing gate. A bounded replay on a fresh lease adds durable command logs and an exit-code record.Final Testbox verification passed on
tbx_01m3ec75esyz08rr6c790e9zm5(lease workflow): frozen dependency installation, localization verification (4,054 unchanged entries), scoped changed-file checks, eight Vitest shards in 131.03s, and native schema guard v19. The verified tree ise5eb41fe0a4362e0a937b75ed92934d25783f905. This passing replay establishes current proof; it does not establish the cause of the earlier interruption. All three leases are stopped:tbx_01m3e9fx3exda3vgqgh7c0hp30,tbx_01m3eavgnzzsfyhd92ybpqrytg, andtbx_01m3ec75esyz08rr6c790e9zm5. The linked lease workflow can show cancellation after cleanup; the proof above is the command result.Rebase verification — September 26
Rebased onto
813169e282faa208e6716c20844b3745c7328e80, which containsf2532a051f7, and pushedb013496b338a102d489a3ebff3cd2b79e5db9d72. The rebase had no conflicts. All reviewed hunks were kept; none were dropped or modified. Range-diff differs only in aChatView.swifthunk label after main moved code into an extension. The aggregate stable patch ID is identical before and after:c769ad3717b67063b8687b8ec7b2cfae50d64f5b. Net production reduction remains 1,089 lines (+809 / -1,898).Apple verification ran locally, serially, at
nice -n 10:swift build --package-path apps/shared/OpenClawKit --build-system native --build-tests --disable-index-store -Xswiftc -gline-tables-only --jobs 4: passed in 404.11s.The temporary test launcher initially failed to load
Testing.frameworkbefore any tests ran because macOS stripped loader variables at the sandbox entry point. Moving those variables to the sanitized environment inside the sandbox fixed the launcher; no repository source or test changed. Operator files, preferences/Keychain and desktop services, network, and arbitrary process execution remained blocked.Fresh exact-head CI is pending. Auto-merge was disabled before and after the push; the coordinator owns re-adding this PR to its watcher. No same-head CI rerun or auto-merge request was submitted. A repeated iPad termination/state-tracking failure on this fresh head will be reported to the post-#147770 harness owner without another rerun.
Previous-head CI investigation (coordinator accepted)
Previous head
e355a63d69e89ad4a9ca52a776a6786aea42bac4was held during the investigation below. The coordinator disabled auto-merge and held the PR. The sole originating failure in the required CI gate isios-screenshots-ipad-13; the other app/package/macOS/iOS smoke and iPhone screenshot lanes passed.Attempt 1 failed during SimSlim setup (
simctl list: signal: killed). The coordinator's single allowed same-head attempt 2 got through setup and the Control/Chat screenshot tests, then failedOpenClawSnapshotUITests.testReleaseAgentScreenshotin teardown, atOpenClawSnapshotUITests.swift:1600,app.terminate().Attempt-2 job and failure artifact 10904295932 were downloaded and inspected. The Agent xcresult reports one test, one failure, not a successful suite. Its screenshot had already been captured and attached at test time 54.23s. The exact error is
Failed to terminate ai.openclawfoundation.app.debug:6498: Failed to terminate ai.openclawfoundation.app.debug:0(XCTest UI-automation error 10013). Xcode exited 65 after 748.34s, including a subsequent 600-second simulator-diagnostics timeout. Fastlane correctly propagated that failure.Attempt-2 attribution and controls
The xcresult's native session diagnostics establish delayed process-state observation:
SimulatorSessionMap.Running Foregroundand fails its wait.not runningstate update, after the deadline.The same-run Control and Chat results receive their not-running updates promptly and pass. The log's separate
Ignoring exit of launch session...message also occurs in those passing controls; it is not treated as the cause.88e2ebeff4f9d1de7fa9a1c535f8b71764b3dfc8ea143eaeae089fedbcc81886d5c01151e73bc28a, d05 into5836021e126c7a0f03750afa5bce5850f045d8e665fbd1e26a1f70017ab4535f656e8839c1c352ea, e355 intoa2792b9a40bb7b3de538b21c01215fc8044d8e6aAll use Xcode 27.0 / 27A266a and iOS 27 runtime v24.1.434.0. Both historical passing controls predate SimSlim. Scheduled main runs skip this screenshot matrix, and no post-SimSlim main screenshot control was found in the bounded search. This is not a matched stock-versus-SimSlim A/B, and it does not prove that SimSlim caused the delayed notification.
The relevant harness owner change is #147770 (
deb168691b2), which enabled SimSlim 0.8.0 and pre-screenshot preparation between the controls and this failure. The termination helper itself dates toebbbfa4c3016and is unchanged here. No existing OpenClaw repair for this exact termination-state failure was found in the bounded search.Attribution: the observed failure is in XCTest/CoreSimulator process-state tracking. The PR changes no
apps/iossource, screenshot test, Fastfile, or simulator-preparation script relative to the tested merge base. Screenshot fixture mode disables real gateway discovery/reconnect and clears active connection configuration, so the retired external-authorization path is not exercised. ChatUI is byte-identical between d05 and e355; the passing pre-deletion control already contains its consolidation, and the same-run Chat screenshot passes. There is no evidence justifying an application-code patch or weakening the teardown assertion.No additional test/build run, CI rerun, code edit, push, or auto-merge action was performed during this investigation. The PR remains held with a red required gate.
The separate advisory Shared Periphery intersection still reports
ChatScrollCommand.Request.idfrom newer main, absent from the PR head. The UUID is required by synthesized equality to distinguish repeated scroll requests; it was not deleted or suppressed.Original review finding resolutions
validated, whose existingisValidEndpointowner retains TLS/fingerprint and local-network restrictions; original/candidate admission probes passed.prepareCacheSchema, which creates session-roster tables before publishing the queue.discoverContextconverts its gateway URL withhttpURLbefore calling privatecontextSnapshot.OpenClawChatOutboxCommand.initstill trims agent IDs and maps empty values to nil.handleOutputAudiounwrapsincomingTurnIdbefore comparing cancellation IDs; nil/nil is unreachable.