Audit and harden the test suite - #504
Open
morluto wants to merge 12 commits into
Open
Conversation
morluto
marked this pull request as ready for review
July 11, 2026 09:26
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Fix six compilation failures that blocked all app test shards: - CodexNativeSessionControllerGoalConfigTests: add explicit `self.` for closure capture semantics in AsyncTestWait condition - MCPSocketDescriptorHardeningTests: mark `condition` parameter as `@escaping` to match AsyncTestWait.waitUntil's escaping closure - MCPToolAdmissionPolicyTests: same `@escaping` fix for `waitUntil` helper - MCPReadFileAutoSelectionCoordinatorTests: drop `@Sendable` from `waitUntil` condition so @MainActor-isolated `debugSnapshot()` is reachable - WorkspaceCodemapLiveOverlayTests: replace undefined `eventually` with `AsyncTestWait.waitUntil` - WorkspaceSwitchPresentationTests: add missing `waitUntil` helper following the WorkspaceSwitchRecoveryTests pattern
On macOS 26, deallocating an NSHostingView during NSWindow teardown can
trigger InvalidTransition { phase: idle, targetPhase: failed(deinit) }
from SwiftUI's internal phase state machine. This caused
testSlashSkillClickSurvivesDelayedRefreshCompletionBeforeAccept to fail
intermittently in CI when the SuggestionWindow was released after
dismissal.
Clear the hosting view reference and contentView in hide() while the
window is still alive, so SwiftUI can tear down its phase state
gracefully before the window is deallocated.
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.
Why this PR exists
The test suite had accumulated several patterns that made failures harder to trust:
The result was a mix of false-pass risk, timing-dependent failures, misleading failure names, and avoidable maintenance overhead. This PR audits those patterns across the root and provider test trees and applies only changes with a clear regression-value improvement.
Review principles
The cleanup follows these rules:
Issues found and addressed
Flaky and brittle asynchronous waits
The audit found repeated variants of:
Task.yield()loops with no real time boundDate()rather than a monotonic clockfalsesilently on timeoutThese were replaced with bounded
AsyncTestWaitconditions, explicit actor hops, or deterministic gates where the state transition is observable.Weak concurrency oracles
The Git admission budget test previously asserted only that concurrency stayed below configured limits. That could pass if the implementation accidentally serialized everything.
The revised test proves both sides of the contract:
repo-ais deterministically active before the remaining repositories raceAutoreview caught and helped repair an intermediate scheduling race in this test before landing.
Compile-time hazards introduced during cleanup
Structured autoreview caught two Swift concurrency/XCTest mistakes in the initial cleanup:
@MainActorpredicates passed directly into a nonisolated async waiterThe final patch explicitly hops to
MainActorand awaits values into locals before asserting.A parallel ledger/diff audit also caught a mistakenly removed
WorkspaceSwitchRecoveryTests.waitUntilhelper that still had live callers. It was restored as a boundedAsyncTestWaitwrapper.Low-value structural coverage
Five executable tests were removed because they asserted source layout, source-fragment ordering, reflected stored-property types, or constant inventories rather than runtime behavior:
root/RepoPromptTests.BindContextRoutingRecoveryTests/testMCPConnectionManagerHasNoIncompleteBindContextFastPathOrUnsafeRegisteredServicesSnapshotroot/RepoPromptTests.StoreBackedWorkspaceSearchTests/testBroadSearchOrchestrationChecksScopeAndReadinessBeforeAndAfterAdmissionroot/RepoPromptTests.StoreBackedWorkspaceSearchTests/testSearchScopeParserKeepsRequiredResolutionOrderroot/RepoPromptTests.CodeMapV6CacheDeletionTests/testReportTelemetryShapeContainsOnlyNumericStoredFieldsroot/RepoPromptTests.ContextBuilderMCPProgressTimelineTests/testPhaseCatalogCoversExpectedDiscoveryAndGenerationSequenceThese tests were vulnerable to harmless refactors and could still pass when behavior was wrong. Existing behavioral tests continue to cover routing, search scope/readiness, cache deletion outcomes, and progress timeline transitions.
Dead and duplicated test support
The cleanup removes unused actors, continuations, recorders, source readers, benchmark formatting helpers, Git fixture helpers, and wait helpers.
It also consolidates two duplicated
write_ledgerimplementations in the CI app-test runner tests. The surviving helper supports both existing call shapes and remains covered by all 52 runner self-tests.Ledger drift and classification
The ledger was reconciled surgically rather than regenerated:
Final static ledger state:
RPCE_BENCHMARK_TESTSCommit structure
test(ci): consolidate ledger fixture helpertest: harden async synchronization helperstest: remove brittle structural coverageValidation performed
make ci-app-test-runner-selftest— 52/52 passedswiftc -frontend -parsegit diff --checkCI handoff
Local execution intentionally did not run the macOS test suite. Hosted CI is the authoritative proof for:
verify-ledgerScope intentionally left unchanged
Two opt-in report-only benchmark methods remain behind
RPCE_BENCHMARK_TESTS. They may be better represented as diagnostics in a future change, but moving benchmark ownership is separate from this test-quality cleanup.Several large omnibus tests also remain intact because splitting them would create substantial executable-ID and ledger churn without fixing a concrete behavioral defect.