Fail closed on app-host test outcomes and remove impossible route waits

Closed
AU
2mo ago
+1594-283

Summary

  • Preserve authoritative mixed-framework failures and total-timeout outcomes instead of allowing an earlier tolerant XCTest summary to pass the job.
  • Reject unknown app-host exit statuses; the regression harness now models XCTest assertion failures with status 65 and includes the real classifier.
  • Bound app-host retries and complete mixed-framework runs, preserve heartbeat behavior, and isolate app-host fixture cleanup.
  • Remove impossible unauthenticated mobile-host route waits from TerminalOffscreenStartupTests by seeding the public route cache directly; tear down headless surfaces deterministically.
  • Keep the debug mobile RPC inventory sorted at its shared declaration; the existing app-host regression caught the out-of-order simulator recovery method.

Verification

  • python3 tests/test_ci_change_areas.py
  • bash tests/test_ci_app_host_xcodebuild_retry.sh
  • python3 tests/test_ci_xcodebuild_noninteractive_helper.py
  • bash tests/test_ci_app_host_identity.sh
  • bash tests/test_ci_app_host_processes.sh
  • bash tests/test_ci_app_host_home_cleanup.sh
  • python3 scripts/check-test-determinism.py --self-test and --strict
  • python3 scripts/check-package-resolved-policy.py
  • python3 scripts/check-workspace-package-groups.py
  • bash scripts/check-pbxproj.sh
  • bash scripts/lint-pbxproj-test-wiring.sh
  • python3 scripts/swift_file_length_budget.py

September 10 resume, pushed HEAD 4ee30db3f4973982076c6dc609c3a15bdb217e3b: local CI-tooling regressions pass, including the complete change-area test runner, noninteractive helper, app-host retry/identity/process/home fixtures, sharding tests (2457 selectors), shared Swift lexer tests (14), determinism fixtures (150 positive + 90 negative), strict determinism scan (0 findings), and the policy/wiring checks above. New regression fixtures were committed separately and observed failing locally before their fixes. No local Xcode build or test was run.

Final-head full CI run 34460787505 is pending, not claimed green. E2E 34458121381 tested SHA fa74034a08 and passed all 29 TerminalOffscreenStartupTests, including the three attach-ticket cases and the inventory-order regression. The app/runtime/test-source trees are unchanged between that SHA and HEAD. Hosted web-typecheck passed at da947bab7f; the web test files are unchanged in HEAD. The prior E2E attribution was corrected in comment 5589141222: run 34248807414 tested branch SHA 7eb9b54add, not main.

Trade-offs

  • The branch is current with main via merge commits, preserving the existing commit provenance instead of rewriting the long PR stack.
  • The origin branch was force-updated with --force-with-lease from its stale pre-rebase SHA; the explicit lease prevented overwriting any intervening origin update.
  • Main's newer XCTest-summary parser is reused by both batch and final classification; this branch retains authoritative Swift Testing failures, deadlines, and unknown-status rejection. Main's idle-progress diagnostics are also retained.
  • Three large Swift Testing suites are kept whole instead of using XCTest-style method selectors. This preserves framework coverage but changes shard composition; broad failures cannot be assumed unrelated without remote verification.
  • No visual evidence is attached because there is no visual change. The only new runtime delta is DEBUG-only RPC inventory ordering, verified through its existing app-host RPC regression. Sorting preserves the complete inventory and does not silently deduplicate it.
  • This includes mobile/iOS release-gate behavior. It will not be self-merged; Austin owns merge approval after the actual done bar.
  • Scope-safe shard detection reuses the existing structural Swift tokenizer, adding a lexical pass to handle attribute order, suite braces, nested comments, raw strings, and interpolation without another lexer implementation.
  • This continuation used three grouped pushes, including post-push CI/review follow-ups. Main-derived web failures were fixed only in test declarations and fixture paths; billing behavior and runtime assertions were not weakened. Final-head CI remains required even though the affected runtime suite already passed.

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


[!NOTE]
Medium Risk
Changes affect CI gating for the full app-host unit suite and agent automatic-resume ownership rules; misclassification could hide real failures or leave stale bindings, though the direction is fail-closed with expanded regression coverage.

Overview
App-host CI now treats Swift Testing and wrapper exit codes as authoritative: sharding emits per-batch Swift Testing metadata, the noninteractive helper enforces total deadlines and reserved statuses (123–127), batches run with -parallel-testing-enabled NO, and classify-app-host-test-result.sh only tolerates ordinary XCTest failures when the log still shows (0 unexpected)—so a stale summary cannot green a missing or failed Swift Testing phase. Ghostty config validation is tightened with canonical path checks (aliases OK, traversal rejected).

Product fixes include not marking agent resume bindings stale when the live index has no entry after a completed scan (only a observed non-live entry counts), rewriting loopback browser URLs with correct IPv6 bracket handling, and sorting the DEBUG mobile RPC inventory for release-gate parity.

Tests and tooling move private-URL and simulator-gesture coverage into dedicated suites, fix attach-ticket tests by seeding MobileHostPublicStatusCache instead of waiting on the unauthenticated status probe, split UserDefaults superseded-source coverage, and extend the determinism scanner for Process.run/curl-style invocations. Several snapshot/cloud/tree expectations were updated for tab-scoped port nodes and parser tab-ID behavior.

Reviewed by Cursor Bugbot for commit 3d8c1be81f1bf87d7bd250d1e24cb0bc0dd0640b. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Fails closed on app-host test outcomes so a tolerant XCTest summary can no longer pass a job with real Swift Testing failures, timeouts, or unknown exit statuses. Also removes impossible unauthenticated mobile-host route waits in TerminalOffscreenStartupTests and fixes related restore and release-gate bugs.

CI hardening

  • classify-app-host-test-result.sh only tolerates ordinary XCTest statuses when the summary shows "(0 unexpected)" and no Swift Testing failure line is present.
  • Reserved exit codes 123–127 cover Swift Testing failures, idle/post-test timeouts, missing Swift Testing phases, and total deadline; app-host xcodebuild forces serial Swift Testing.
  • Ghostty config paths are canonicalized so a symlink alias is accepted but traversal through it is rejected.
  • check-test-determinism.py flags curl/wget inside Process.run, exec, and multiline shell strings, while allowing a wrapped deadline-timeout race.

Bug fixes and test updates

  • Rewrites loopback URLs with correct IPv6 brackets, and classifies deferred browser URLs so a restored-but-not-yet-loaded tab is no longer an empty new tab.
  • A completed index scan with no matching entry no longer marks a fresh agent binding stale; only observed non-live process evidence does.
  • Attach-ticket tests seed MobileHostPublicStatusCache directly, headless startup tests tear down surfaces deterministically, and the mobile debug RPC inventory is sorted.
  • Superseded-source and simulator-gesture suites are wired into the app target with Bun fixture updates, and the cloud VM reference now documents the vm.diagnostics RPC.

Summary by CodeRabbit

  • Bug Fixes

    • Improved automated test-result classification across XCTest and Swift Testing, including mixed suites, timeouts, incomplete runs, and expected failures.
    • Strengthened configuration-path validation to reject unsafe or invalid paths while accepting valid aliases.
    • Improved test cleanup and reduced reliance on service polling in mobile attachment tests.
    • Improved detection of network-dependent test commands.
  • Tests

    • Expanded coverage for timeout handling, retries, path validation, network detection, and result classification.
  • Chores

    • Added configurable total timeouts and Swift Testing expectations for noninteractive test runs.