[TEST] keychain test isolation — sweep stray items in isolated-home teardown - #23
Open
gradyzhuo wants to merge 3 commits into
Open
[TEST] keychain test isolation — sweep stray items in isolated-home teardown#23gradyzhuo wants to merge 3 commits into
gradyzhuo wants to merge 3 commits into
Conversation
The macOS login Keychain is global — ORRERY_HOME does not isolate it — so tests that run claude keychain writes (notably AccountMigrationTests via AccountMigration.runIfNeeded -> migrateOrigin(claude), which reads the real Claude Code-credentials service) leave stray Claude Code-orrery-* items in the developer's real keychain (~2900 had accumulated; the suite added ~7/run). Add sweepClaudeKeychain(home:) and call it from withIsolatedHome and AccountMigrationTests.makeTempHome teardown — deletes each isolated claude account's per-account service (by name) after the test. Test-only; no production change. Reduces per-run growth from ~7 to a residual ~1 from an as-yet-unpinned source (needs runtime instrumentation; tracked as follow-up).
…no production seam)
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.
Test-only fix (no production changes). Implements
docs/superpowers/specs/2026-07-07-keychain-test-isolation-design.md.Problem
The macOS login Keychain is global —
ORRERY_HOMEdoesn't isolate it. Tests that run a claude keychain write against the realClaude Code-credentialsservice leave strayClaude Code-orrery-<uuid>items in the developer's real keychain. ~2894 had accumulated; a fullswift testadded ~7/run. Primary source:AccountMigrationTests→AccountMigration.runIfNeeded→migrateOrigin(.claude)reads the real default service and copies it to a new per-account service.Fix (test harness only)
sweepClaudeKeychain(home:)(TestHelpers.swift): after a test, delete each isolated claude account's per-account keychain service (the deterministicserviceName(forOrreryAccount:)+ any explicitkeychainItem), by service name.withIsolatedHomeandAccountMigrationTests.makeTempHome.KeychainAccess-seam draft was rejected as churn for a test-only concern).Result
Known follow-up
A residual ~1/run remains from a source not identifiable by static analysis. Pinning it needs runtime instrumentation (temporary stack-trace in
ClaudeKeychainwrite funcs, reverted after) — deferred to a focused follow-up.🤖 Generated with Claude Code