Skip to content

test(swift-sdk): make resolver sign tests hermetic to CI keychain state - #4386

Open
QuantumExplorer wants to merge 2 commits into
v4.2-devfrom
claude/ci-issue-873e45
Open

test(swift-sdk): make resolver sign tests hermetic to CI keychain state#4386
QuantumExplorer wants to merge 2 commits into
v4.2-devfrom
claude/ci-issue-873e45

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Aug 12, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

The "Swift SDK build + tests (warnings as errors)" job fails intermittently on the self-hosted mac runners with keychainError from WalletStorage-60008 (errAuthorizationInternal) on mac-runner-2 and now -61 (errSecWrPerm) on mac-runner-1 (e.g. this run on an unrelated PR). The two IdentityResolverSignIntegrationTests cases were the only tests in the swift test phase writing to the real macOS keychain, so they fail whenever a runner's keychain session is locked or permission-denied — even with the dedicated CI keychain run_tests.sh provisions.

What was done?

  • KeychainSigner.init now accepts an injectable WalletStorage (defaulting to the real one), forwarded to its MnemonicResolver — the same "overridable for tests" pattern already used by MnemonicResolver and ManagedPlatformWallet.
  • IdentityResolverSignIntegrationTests uses an in-memory WalletStorage subclass, so the derive-sign-destroy resolver path under test never touches keychain state.

How Has This Been Tested?

  • swift test --filter IdentityResolverSignIntegrationTests — both tests pass, with the resolver trampoline confirmed firing through the injected storage.
  • Full swift test: 349 tests, 0 failures.

Breaking Changes

None — the new parameter is defaulted; existing call sites are unchanged.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for providing custom wallet storage when initializing the keychain signer.
    • The default wallet storage behavior remains unchanged.
  • Tests

    • Improved integration test reliability by using isolated in-memory wallet storage instead of the system keychain.

The two IdentityResolverSignIntegrationTests cases were the only tests
in the `swift test` phase that wrote to the real macOS keychain, and
they fail whenever a self-hosted runner's keychain session is locked or
permission-denied (keychainError -60008 on mac-runner-2, -61 on
mac-runner-1) — even with the dedicated CI keychain run_tests.sh
provisions.

KeychainSigner now accepts an injectable WalletStorage (defaulting to
the real one, matching the existing "overridable for tests" pattern on
MnemonicResolver and ManagedPlatformWallet), and the tests use an
in-memory subclass so the derive-sign-destroy path under test never
touches keychain state.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@QuantumExplorer, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 13 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d84dc88c-b7b2-4df7-be8f-231c57c12605

📥 Commits

Reviewing files that changed from the base of the PR and between ff15f08 and 1d86a94.

📒 Files selected for processing (2)
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift
  • packages/swift-sdk/SwiftTests/SwiftDashSDKTests/IdentityResolverSignIntegrationTests.swift
📝 Walkthrough

Walkthrough

KeychainSigner now accepts injectable wallet storage and passes it to MnemonicResolver. Resolver integration tests use a thread-safe in-memory storage implementation instead of the default storage.

Changes

Wallet storage injection

Layer / File(s) Summary
Signer storage wiring
packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift
KeychainSigner accepts a WalletStorage parameter and passes it to MnemonicResolver.
Integration test storage
packages/swift-sdk/SwiftTests/SwiftDashSDKTests/IdentityResolverSignIntegrationTests.swift
The tests add thread-safe in-memory mnemonic storage and inject it into both KeychainSigner test paths.

Estimated code review effort: 2 (Simple) | ~10 minutes

Mergeability Score: 🟡 Moderate · up to ff15f

The signing path can reject a valid resolver-backed key before signing because its preflight check does not use the injected storage. This is a bounded correctness issue that should be fixed before merging.

Suggested reviewers: shumkov, llbartekll, zocolini

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: making Swift SDK resolver signing tests independent of CI keychain state.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/ci-issue-873e45

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 1d86a94)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift`:
- Around line 197-204: Retain the initializer’s injected WalletStorage as a
KeychainSigner property, and update both hasMnemonic checks in
canSign(publicKey:keyType:) to use that property instead of creating new
WalletStorage instances. Add a canSign assertion to the successful
resolver-backed integration test.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d4ceb0f6-3bdc-4ece-bffa-f5dbb57d535e

📥 Commits

Reviewing files that changed from the base of the PR and between 806890c and ff15f08.

📒 Files selected for processing (2)
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift
  • packages/swift-sdk/SwiftTests/SwiftDashSDKTests/IdentityResolverSignIntegrationTests.swift

Comment thread packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift
The canSign hasMnemonic preflights constructed fresh WalletStorage()
instances, so with an injected storage the preflight and the sign path
answered from different stores — a resolver-signable key could preflight
as unsignable. Retain the injected storage and consult it in both
checks; the in-memory test storage overrides mnemonicAvailability and
the successful-sign test now asserts canSign first.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Codex/Sol only (Phase 2 disabled)

The exact-head diff correctly injects one shared WalletStorage into KeychainSigner, its MnemonicResolver, and both canSign preflight branches while preserving production behavior through the default argument. The resolver integration tests now use synchronized in-memory storage and explicitly cover successful canSign; no in-scope issues remain.
Source: reviewer backend model gpt-5.6-sol; final verifier backend model gpt-5.6-sol; orchestration-only openclaw-agent/cliproxy/gpt-5.6-sol (not reviewer evidence).

Validated zero-blocker Codex/Sol precheck evidence was promoted to final because Phase 2 (Sonnet/Opus) is temporarily disabled. This is Codex/Sol-only final validation, not Codex + Sonnet/Opus coverage.

Review provenance

  • Codex reviewers: gpt-5.6-sol — general (completed)
  • Verifier: gpt-5.6-sol — verifier
  • Sonnet/Opus: not run (Phase 2 disabled — temporary Codex/Sol-only final)
  • Secondary pass: disabled (temporary_phase2_sonnet_disable)

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.

2 participants