Skip to content

Isolate Claude CLI gating tests#2320

Merged
steipete merged 1 commit into
mainfrom
codex/fix-claude-cli-gating-flakes
Jul 19, 2026
Merged

Isolate Claude CLI gating tests#2320
steipete merged 1 commit into
mainfrom
codex/fix-claude-cli-gating-flakes

Conversation

@steipete

Copy link
Copy Markdown
Owner

Summary

  • isolate TTYCommandRunnerActiveProcessRegistry behind a task-local state override so shutdown-fence tests cannot reject unrelated concurrent Claude login launches
  • serialize the complete Linux PlatformGatingTests suite, completing the partial Claude CLI gating serialization from Serialize flaky Claude CLI platform-gating cases #2311
  • make Claude auth-status timeout overrides task-local and widen only test fixture deadlines that proved load-sensitive; production defaults and behavior are unchanged
  • harden the named Kiro pipe-deadline assertion without changing the probe implementation

Root cause

TTYCommandRunnerEnvTests is serialized only within its own suite. Its shutdown-fence cases mutate the process-global TTYCommandRunnerActiveProcessRegistry.isShuttingDown flag, while ClaudeLoginRunnerTests concurrently call TTYCommandRunner.run. When the fence wins, beginLaunch() rejects the Claude fixture launch and all three login tests receive launchFailed/empty output instead of their expected auth link or exit result.

The exact concurrent reproducer was:

swift test --filter 'ClaudeLoginRunnerTests|TTYCommandRunnerEnvTests'

It failed before the fix and now passes all 31 tests. The isolated registry state is task-local; the one test that crosses to a detached Thread explicitly captures its scoped state.

The Linux gating failure is a neighboring isolation class: #2311 serialized only the parameterized logged-out test's argument cases, not that test against the rest of PlatformGatingTests. Suite-level serialization closes that gap, while task-local auth timeout control keeps slow arm64 fake-CLI fixtures inside a test-only budget.

Verification

  • swift test --filter ClaudeLoginRunnerTests
  • swift test --filter 'ClaudeLoginRunnerTests|TTYCommandRunnerEnvTests' — 31 tests passed
  • arm64 Docker PlatformGatingTests — 10 consecutive focused runs passed
  • swift build -c release — passed in 218.64s
  • make check — SwiftFormat clean; SwiftLint 0 violations in 1,577 files
  • three consecutive make test runs on the final debug implementation:
    • 60/60 first-pass groups, 719 selections, 0 retries/timeouts, 692.8s
    • 60/60 first-pass groups, 719 selections, 0 retries/timeouts, 575.6s
    • 60/60 first-pass groups, 719 selections, 0 retries/timeouts, 477.9s
  • autoreview: no accepted/actionable findings

swift test -c release was also attempted after making the new seams configuration-independent. It compiled past this patch and then hit existing unrelated DEBUG-only OAuth test seams in ClaudeOAuthDelegatedRefreshLinuxTests; the production release build is green.

No changelog edit here; this is an internal test-infrastructure fix.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal priority bug or improvement with limited blast radius. labels Jul 19, 2026
@clawsweeper

clawsweeper Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed July 19, 2026, 12:30 AM ET / 04:30 UTC.

Summary
The PR refactors TTY active-process tracking to support task-local test isolation, serializes Linux platform-gating tests, and widens test fixture timeouts without changing production defaults.

Reproducibility: yes. at source level: the PR identifies a concrete concurrent path where shutdown-fence tests mutate shared registry state while Claude login fixtures launch processes. The provided focused command is a plausible reproducer, but it was not rerun during this read-only review.

Review metrics: 2 noteworthy metrics.

  • Patch surface: 8 files affected; 266 additions, 149 deletions. Most of the patch is a contained test-state refactor plus focused fixture and suite changes, rather than a production feature change.
  • Validation claimed: 3 full-suite runs; 31-test focused reproducer; 10 arm64 focused runs. The PR provides unusually concrete flake-validation evidence, pending confirmation from the exact-head CI matrix.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Allow the in-progress macOS and Linux checks to complete on the current head before merging.

Risk before merge

  • [P1] The exact branch still has in-progress macOS and Linux CI jobs, so the intended reduction in load-sensitive failures is not independently confirmed by the current check matrix yet.

Maintainer options:

  1. Decide the mitigation before merge
    Retain the task-local registry isolation as the root-cause fix, keep Linux serialization limited to the flaky test suite, and merge after the exact-head macOS/Linux matrix confirms the reported focused and full-suite behavior.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] No discrete automated repair is identified; this maintainer-authored patch needs normal review and completion of the existing CI matrix.

Security
Cleared: The diff changes internal process-test state and test fixtures only; no dependency, workflow, secret, packaging, or privilege boundary change is evident.

Review details

Best possible solution:

Retain the task-local registry isolation as the root-cause fix, keep Linux serialization limited to the flaky test suite, and merge after the exact-head macOS/Linux matrix confirms the reported focused and full-suite behavior.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: the PR identifies a concrete concurrent path where shutdown-fence tests mutate shared registry state while Claude login fixtures launch processes. The provided focused command is a plausible reproducer, but it was not rerun during this read-only review.

Is this the best way to solve the issue?

Yes. Task-local test state addresses the shared mutable-state cause more directly than broad serialization, while suite serialization remains limited to the separately flaky Linux gating fixture group.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 242469b5b23e.

Label changes

Label changes:

  • add P2: This is a bounded reliability improvement for flaky test infrastructure, with no stated production behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is maintainer-authored test-infrastructure work, so the external contributor proof gate does not apply; the PR body nevertheless supplies focused and full-suite after-fix validation results.

Label justifications:

  • P2: This is a bounded reliability improvement for flaky test infrastructure, with no stated production behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is maintainer-authored test-infrastructure work, so the external contributor proof gate does not apply; the PR body nevertheless supplies focused and full-suite after-fix validation results.
Evidence reviewed

What I checked:

Likely related people:

  • steipete: The repository owner authored the current focused test-infrastructure change and is the clearest routing point for its intended concurrency boundary. (role: likely follow-up owner; confidence: medium; commits: a3cac151f9c0; files: Sources/CodexBarCore/Host/PTY/TTYCommandRunner.swift, Sources/CodexBarCore/Providers/Claude/ClaudeCLIAuthStatusProbe.swift)
  • Chipagosfinest: Authored the merged Linux platform-gating containment change that this PR explicitly completes at suite scope. (role: recent adjacent contributor; confidence: high; commits: ad7ee2f807db; files: TestsLinux/PlatformGatingTests.swift)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 663099e into main Jul 19, 2026
9 checks passed
@steipete

Copy link
Copy Markdown
Owner Author

Merged as 663099e8f9fb2680dabeaa811e844dd6090ea9aa after exact-head CI completed green.

Root cause: TTYCommandRunnerActiveProcessRegistry.isShuttingDown was process-global. The shutdown-fence cases in TTYCommandRunnerEnvTests set that flag while ClaudeLoginRunnerTests concurrently entered TTYCommandRunner.run; beginLaunch() then rejected the unrelated Claude fixture launch, producing launchFailed/empty output and a missing auth link. Suite-level .serialized never isolated those two separate suites.

Fix: the active-process registry now resolves through a task-local isolated State in tests, while its default remains the shared production state. The detached-thread shutdown case explicitly captures its scoped registry state because task locals do not propagate to a raw Thread. PlatformGatingTests is serialized at suite scope, completing #2311's partial parameter-case serialization. Claude auth-status timing uses a task-local test override; the remaining timing changes are fixture-only, including the named Kiro deadline assertion. Production defaults are unchanged.

Verification:

  • swift test --filter ClaudeLoginRunnerTests passed.
  • swift test --filter 'ClaudeLoginRunnerTests|TTYCommandRunnerEnvTests': 31 tests passed concurrently. This command failed before the registry isolation and passed after it.
  • arm64 Docker focused PlatformGatingTests: 10 consecutive runs passed.
  • swift build -c release: passed in 218.64s.
  • make check: SwiftFormat clean; SwiftLint reported 0 violations in 1,577 files.
  • Three consecutive make test runs on the final debug implementation each passed 60/60 groups and all 719 selections with 0 first-pass failures, 0 retries, and 0 timeouts: 692.8s, 575.6s, and 477.9s.
  • Final local autoreview and branch autoreview both reported no accepted/actionable findings.
  • Exact-head CI run 29673366301 on a3cac151f9c05b9a33822e9116a7363b6b63dd36: 9 passed, 0 pending, 0 failed, 0 cancelled. This includes build-linux-cli (linux-arm64, ubuntu-24.04-arm), Linux x64, Linux musl, both macOS test shards, lint, and security checks.

swift test -c release was additionally attempted. It compiled past this patch's configuration-independent test seams, then stopped on pre-existing unrelated DEBUG-only OAuth seams in ClaudeOAuthDelegatedRefreshLinuxTests; the production release build above is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant