Skip to content

Test bounded stale-port retirement after listener exit - #11356

Merged
austinywang merged 4 commits into
mainfrom
issue-11294-stale-port-badges
Sep 3, 2026
Merged

austinywang merged 4 commits into
mainfrom
issue-11294-stale-port-badges

Conversation

@austinywang

@austinywang austinywang commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add deterministic CmuxCore coverage for a listener publishing port 48123, exiting, and retiring from both panel and workspace snapshots within the existing six-scan burst
  • add app-model coverage proving the final empty panel and agent/workspace values coalesce through PortScanPublicationBuffer
  • preserve the current conservative two-miss retention contract; the third complete miss retires the port

Context

The reported stable build, 0.64.22 (102) [ddd4a01bc], predates the runtime fix in #10633 and the scanner follow-up in #11109. Current main already has the fix; this PR locks that behavior in without changing runtime code.

Closes #11294

Verification

  • /usr/bin/arch -arm64 /usr/bin/xcrun swift test --filter PortScan — 11 tests passed
  • ./scripts/lint-pbxproj-test-wiring.sh — checked 732 test files
  • ./scripts/check-pbxproj.sh
  • python3 scripts/check-package-resolved-policy.py
  • python3 scripts/check-workspace-package-groups.py --check

No local xcodebuild or XCUITest invocation was used.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Adds regression coverage for bounded stale-port retirement after a listener exits, locking in current-main behavior without changing runtime code. Closes #11294.

  • Verifies CmuxCore retains a stopped port for two complete misses and removes it from panel and workspace snapshots on the third.
  • Verifies buffered panel and agent/workspace publications converge to empty values within the same scan burst.

Written for commit a6196cd. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Tests
    • Added regression coverage for port publication behavior when listeners stop.
    • Verified that panel and workspace publications persist through two consecutive empty scans and are cleared on the third completed scan.
    • Added coverage for consistent retirement behavior across multiple scopes.

Verification notes

The intentional trade-off is to add authoritative behavior coverage without re-implementing retirement: #10633/#11109 already fix runtime behavior on main, while stable 0.64.x predates those fixes. The PR therefore needs a release containing current main; it does not add a second retirement owner or timing workaround.

Hosted scanner verification

  • Hosted run #13755 on warp-macos-15-arm64-6x succeeded at the exact HEAD dcfda79bfab. Its app-host xcodebuild compiled the test bundle and ran all 3 PortScannerPortRetirementTests: publishedPortIsRetiredAfterProcessStopsListening, lateBurstKickRetiresStoppedListener, and liveFullPathTTYAttributesListener.
  • That suite drives the real PortScanner registration → kick → coalesce/burst → scan → reconcile → publication path with real PID identity checks and a deterministic listener lifecycle fixture; the fixture intentionally stubs command output, so it is not a claim of an OS-level TCP socket/lsof test. The AWS direct-app attempt reached socket health but could not expose a TabManager window in its headless session.
  • Running scripts/swift_warning_budget.py against the full hosted log reports existing main/Xcode warning debt (385 warnings across 241 buckets versus the checked budget); neither changed regression file emitted a warning, and no warning-budget TSV was modified.

@vercel

vercel Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cmux166 Ready Ready Preview Sep 2, 2026 10:29am UTC
cmux41 Canceled Canceled Sep 2, 2026 10:29am UTC

@coderabbitai

coderabbitai Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 80d9a9a5-4bbe-41b7-b25f-0edce887b2e8

📥 Commits

Reviewing files that changed from the base of the PR and between 5383cb9 and a6196cd.

📒 Files selected for processing (3)
  • Packages/macOS/CmuxCore/Tests/CmuxCoreTests/PortScanAuthoritativeRetirementRegressionTests.swift
  • cmux.xcodeproj/project.pbxproj
  • cmuxTests/PortRetirementPublicationRegressionTests.swift

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The pull request adds regression tests for delayed port retirement across panel and workspace scopes. It registers the new test file in the Xcode test target.

Changes

Port retirement regression coverage

Layer / File(s) Summary
Reconciliation retirement tests
Packages/macOS/CmuxCore/Tests/CmuxCoreTests/PortScanAuthoritativeRetirementRegressionTests.swift, cmuxTests/PortRetirementPublicationRegressionTests.swift
The tests publish port 48_123, run three complete scans with empty port lists, verify two retained publications, and verify retirement on the third scan.
Test target registration
cmux.xcodeproj/project.pbxproj
The new test file has a file reference, test-group entry, build-file entry, and Sources build-phase entry.

Estimated code review effort: 3 (Moderate) | ~15–30 minutes

Merge Risk: ⚪ Minimal · up to a6196

This change adds deterministic regression coverage and test-target wiring without modifying production runtime behavior; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: regression coverage for bounded stale-port retirement after a listener exits.
Description check ✅ Passed The description provides a clear summary, context, verification results, limitations, and scope. It omits the template checklist, review-trigger block, and demo-video section, but these omissions are …
Linked Issues check ✅ Passed The changes address issue [#11294] by adding regression coverage for listener retirement in panel and workspace snapshots, including buffered empty publications. The tests verify the documented two-mi…
Out of Scope Changes check ✅ Passed The changes are limited to regression tests and Xcode test-target wiring. They support issue [#11294] and do not introduce unrelated runtime or product changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 …
Cmux Swift Actor Isolation ✅ Passed PASS: The PR diff adds only two Swift test files and registers one test file in the Xcode project. It introduces no production Swift models, protocols, services, shared mutable Sendable references, or…
Cmux Swift Blocking Runtime ✅ Passed PASS — The isolated PR diff changes only two Swift test files and Xcode test-target wiring. The tests use finite for miss in 1...3 iterations and contain no semaphores, waits, sleeps, delayed dispat…
Cmux Browser Automation Off-Main ✅ Passed The pull request adds only port-scan regression tests and Xcode test wiring. The browser automation rule applies to browser socket commands in Sources/TerminalController.swift and `Packages/macOS/Cm…
Cmux Expensive Synchronous Load ✅ Passed PASS: The pull-request diff adds only two test files and Xcode test-target wiring. The changed Swift code calls PortScanSnapshotReconciler and PortScanPublicationBuffer; it does not add production…
Cmux Cache Substitution Correctness ✅ Passed PASS: The pull-request diff contains only two new Swift test files and four Xcode test-target wiring lines. It does not change production Swift, TypeScript, or JavaScript, and it does not substitute a…
Cmux No Hacky Sleeps ✅ Passed PASS. The pull-request diff adds only two Swift test files and Xcode project wiring. It adds no production TypeScript, JavaScript, shell, or build/runtime script changes, and the added lines contain n…
Cmux Algorithmic Complexity ✅ Passed PASS. The PR-only commits change two test files and add their Xcode test-target wiring; they introduce no production Swift, TypeScript, JavaScript, shell, or runtime code. The added loops run exactly …
Cmux Swift Concurrency ✅ Passed PASS: The PR adds only two Swift test files and Xcode test wiring. The added tests use synchronous reconcile and publication-buffer calls. The exact PR patch adds no DispatchQueue, DispatchGroup…
Cmux Swift @Concurrent ✅ Passed PASS: The PR changes only two synchronous Swift test functions plus Xcode project wiring. Neither added test uses async, await, nonisolated, @concurrent, @MainActor, Task, or heavy I/O/net…
Cmux Swift Package Boundaries ✅ Passed PASS. The isolated PR series changes only two Swift test files and test-target wiring in cmux.xcodeproj; it introduces no production Swift paths. `PortScanAuthoritativeRetirementRegressionTests.swif…
Full details: Description check

Explanation

The description provides a clear summary, context, verification results, limitations, and scope. It omits the template checklist, review-trigger block, and demo-video section, but these omissions are non-critical for this test-only change.

Full details: Linked Issues check

Explanation

The changes address issue [#11294] by adding regression coverage for listener retirement in panel and workspace snapshots, including buffered empty publications. The tests verify the documented two-miss retention contract and retirement on the third complete miss.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

Full details: Cmux Swift Actor Isolation

Explanation

PASS: The PR diff adds only two Swift test files and registers one test file in the Xcode project. It introduces no production Swift models, protocols, services, shared mutable Sendable references, or UI-store access. The changed declarations are test suites and test helpers, which the check explicitly allows.

Full details: Cmux Swift Blocking Runtime

Explanation

PASS — The isolated PR diff changes only two Swift test files and Xcode test-target wiring. The tests use finite for miss in 1...3 iterations and contain no semaphores, waits, sleeps, delayed dispatch, polling loops, main-queue sync, or manual locks. The finite test scaffolding is explicitly allowed, and no production Swift code changed.

Full details: Cmux Browser Automation Off-Main

Explanation

The pull request adds only port-scan regression tests and Xcode test wiring. The browser automation rule applies to browser socket commands in Sources/TerminalController.swift and Packages/macOS/CmuxControlSocket/.../ControlCommandExecutionPolicy.swift; no changed path or described behavior concerns browser socket automation, WebKit waits, worker routing, or policy tests.

Full details: Cmux Expensive Synchronous Load

Explanation

PASS: The pull-request diff adds only two test files and Xcode test-target wiring. The changed Swift code calls PortScanSnapshotReconciler and PortScanPublicationBuffer; it does not add production Swift code, agent-history loaders, transcript or JSON/JSONL parsing, directory scans, or synchronous syscalls on an interactive path. The repository rule therefore does not identify a failure.

Full details: Cmux Cache Substitution Correctness

Explanation

PASS: The pull-request diff contains only two new Swift test files and four Xcode test-target wiring lines. It does not change production Swift, TypeScript, or JavaScript, and it does not substitute a cached value for an authoritative read in a production persistence, history, undo, or snapshot path.

Full details: Cmux No Hacky Sleeps

Explanation

PASS. The pull-request diff adds only two Swift test files and Xcode project wiring. It adds no production TypeScript, JavaScript, shell, or build/runtime script changes, and the added lines contain no sleep, timer, polling, or fixed-delay logic. Deterministic test scaffolding is explicitly allowed by the rule.

Full details: Cmux Algorithmic Complexity

Explanation

PASS. The PR-only commits change two test files and add their Xcode test-target wiring; they introduce no production Swift, TypeScript, JavaScript, shell, or runtime code. The added loops run exactly three iterations over fixed test data, and the Set contains only .panel and .workspace. The rule explicitly passes test-only scaffolding and tiny fixed-size collections.

Full details: Cmux Swift Concurrency

Explanation

PASS: The PR adds only two Swift test files and Xcode test wiring. The added tests use synchronous reconcile and publication-buffer calls. The exact PR patch adds no DispatchQueue, DispatchGroup, Combine state, completion-handler API, or fire-and-forget Task pattern. No runtime Swift code changes are present.

Full details: Cmux Swift `@Concurrent`

Explanation

PASS: The PR changes only two synchronous Swift test functions plus Xcode project wiring. Neither added test uses async, await, nonisolated, @concurrent, @MainActor, Task, or heavy I/O/network work. The tests call synchronous PortScanSnapshotReconciler.reconcile, PortScanPublicationBuffer.enqueue, and takePendingBatch. No changed runtime async function or UI-isolated call site is present.

Full details: Cmux Swift Package Boundaries

Explanation

PASS. The isolated PR series changes only two Swift test files and test-target wiring in cmux.xcodeproj; it introduces no production Swift paths. PortScanAuthoritativeRetirementRegressionTests.swift is under Packages/macOS/CmuxCore/Tests, and the other file is under cmuxTests. The boundary policy explicitly allows test code and test fixtures, so no package-boundary violation is introduced.

✨ 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 issue-11294-stale-port-badges

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 3 files

Re-trigger cubic

@austinywang

austinywang commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Final review audit — rechecked against HEAD d54e736d9348dfaedab617a7c279c9a3ef464309 (rebased onto current origin/main 9e2dd50957936153ca0da61d2f079937674f9375).

Comment ID Author File:line Ask Disposition Commit SHA
IC_kwDORDHQWM8AAAABRz8_9Q coderabbitai[bot] Packages/macOS/CmuxCore/Tests/CmuxCoreTests/PortScanAuthoritativeRetirementRegressionTests.swift:13; cmuxTests/PortRetirementPublicationRegressionTests.swift:13 Add intent docstrings to the two touched test functions; the latest review body has no new actionable findings. fix — both doc comments are present in the final diff d54e736d9348dfaedab617a7c279c9a3ef464309
PRR_kwDORDHQWM8AAAABLn8wLA cubic-dev-ai[bot] top-level review “No issues found” across the changed files. already-fixed — no code action requested d54e736d9348dfaedab617a7c279c9a3ef464309
IC_kwDORDHQWM8AAAABR_c97Q cursor[bot] top-level review Bugbot is paused because the on-demand spend limit was reached. already-fixed — informational status only; no finding or ask d54e736d9348dfaedab617a7c279c9a3ef464309
IC_kwDORDHQWM8AAAABRz89RQ vercel[bot] top-level deployment status Report preview deployment state. already-fixed — status-only, no code ask; Vercel contexts are non-required d54e736d9348dfaedab617a7c279c9a3ef464309
IC_kwDORDHQWM8AAAABR-i8KQ github-actions[bot] top-level CLA status Report CLA signature state. already-fixed — the latest CLA Assistant v2, compatibility, policy, and trigger contexts are green d54e736d9348dfaedab617a7c279c9a3ef464309

Codex and Greptile have no top-level review body or inline thread on this PR. Final recheck against HEAD: hosted run #13824 (33575007769) succeeded and ran all 3 PortScannerPortRetirementTests; required CI contexts are green; 0 inline comments; 0 review threads; 0 CHANGES_REQUESTED. GitHub reports mergeable=true but mergeStateStatus=blocked because at least one approving review is required. No merge was performed because the author cannot provide an independent approval.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@austinywang
austinywang force-pushed the issue-11294-stale-port-badges branch from dcfda79 to d54e736 Compare September 2, 2026 00:11
@cursor

cursor Bot commented Sep 2, 2026

Copy link
Copy Markdown

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@austinywang
austinywang merged commit 723958e into main Sep 3, 2026
15 checks passed
rustybret pushed a commit to rustybret/bmux that referenced this pull request Sep 3, 2026
3cce67c Vault: recency-first All Sessions view, session search, and checkpoints with fork (manaflow-ai#10215)
94f51fb Fix aggregate child memory pressure before compressor exhaustion (manaflow-ai#10773)
13006ef cloud: surface whether after() has waitUntil for deferred create work (manaflow-ai#11782)
75eee0e Cloud VMs: bake the TigerVNC desktop (dock, wallpaper, cua-driver, noVNC) into the devbox recipe and open it at the machine's private address (manaflow-ai#11776)
36b5536 Fix terminal text bleed during live window resize (manaflow-ai#11530)
44b42c1 Cloud VMs: machines usage decoder and refresh fixes, edge smoke diagnostics (manaflow-ai#11759)
f11be3a ci(tui): scope Valgrind test compilation (manaflow-ai#11750)
9184f4c coderouter: many Claude upstream accounts per team, routed with affinity and cooldown failover (manaflow-ai#11775)
d3b9cdd cloud: attach waits for the baked supervisor; edge probe span joins the create trace (manaflow-ai#11777)
c69e317 test: make the cmuxTests target compile again (main-actor call, CLI-only type) (manaflow-ai#11770)
8185825 fix(history): stop idle History menu graph rebuild loop (manaflow-ai#10661)
723958e Test bounded stale-port retirement after listener exit (manaflow-ai#11356)
367682e Fix native terminal Copy honoring Ghostty clipboard flavor (manaflow-ai#11515)
d59055d docs(tui): refresh SDK inventory counts (manaflow-ai#11766)
89e4701 cmux-tui: use JoinSet shutdown for simple drains (manaflow-ai#11745)

# Conflicts:
#	.github/workflows/cmux-tui.yml

This branch was successfully deployed

2 active deployments
Preview – cmux41 — a6196cd0 Deployed Sep 2, 2026 by vercel[bot]
Preview – cmux166 — a6196cd0 Deployed Sep 2, 2026 by vercel[bot]
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.

Port badges stay listed after the listening process exits (regression of #9152/#10007, reproduces on 0.64.22 build 102)

1 participant