Skip to content

Send the iPhone test's resume over a socket and log fixture stalls - #265

Merged
BunsDev merged 4 commits into
mainfrom
ios-resume-flake
Oct 16, 2026
Merged

BunsDev merged 4 commits into
mainfrom
ios-resume-flake

Conversation

@BunsDev

@BunsDev BunsDev commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Why the paired iPhone flow timed out on /resume

Three iPhone companion failures on 2026-10-15/16 (38707861067, 38747016392, 38832248437, attempt 1 each) timed out on the paused-Mac /resume call. The simulator's unified log, which each iphone-test-results xcresult carries under simctl_diagnostics/<device>/system.logarchive, shows two causes.

1. The test runner's first URLSession use (fixed here). resumeMac is the only request the UI-test runner makes, so URLSession set itself up at that step, minutes after the simulator booted. That setup goes through cfprefsd, nsurlsessiond's storage container and trustd:

Run Call to request on the wire Reply
38747016392 a1 (red) never, in 44 s (22 s main-thread block, then 20 s in CFNetwork storage setup) none
38707861067 a1 (red) 20 s none in 8.4 s
38832248437 a1 (red) 1.3 s none in 10 s
38832248437 a2 (green) 0.16 s 204 in 72 ms
38836144274 a1 (green) 0.08 s 204 in 62 ms

resumeMac now POSTs over a plain BSD socket to 127.0.0.1 (UITests/LoopbackPost.swift), which needs none of those daemons. It shares one UITestBudget.seconds(10) deadline across connect, send and reply. The old 10 s URLRequest.timeoutInterval was the one wait the suite's scale did not cover. A failure now names the phase it stalled in. Four new tests in CompanionFlowTests cover a 204, a silent fixture timing out at the deadline, a refused port failing fast and a non-IPv4 URL.

2. The Node fixture going silent (instrumented, still open). In 38707861067 and 38832248437 the POST did reach the fixture. It neither answered nor restarted the companion (the phone kept getting connection refused), yet it exited at once on SIGTERM when the job ended. #254's run 38848571338 failed the same way at the first reply. The fixture left a snapshot request and then a TLS ClientHello unanswered for about 5 s and 8 s. The app marked the Mac disconnected, and the create-thread tap landed on the now-disabled button 0.2 s later, so the create was never sent. Locally the fixture answers /resume in 3 ms after 8–80 s outages, and CompanionServer.dispose() returns in ≤1 ms with a phone connection idle, mid-handshake, half-open or mid-body. The fixture prints nothing, so fixture.mjs now logs:

  • the phone's create, send and answer calls
  • pause and resume
  • every event-loop stall of 1 s or more, with the CPU time, major faults and involuntary context switches during it

That tells our own work, paging and a starved process apart. A local SIGSTOP of 2 s logs event loop stalled 1827 ms: cpu 0 ms, major faults 0, ….

Overall XCTest load did not separate red from green: green 38832248437 attempt 2 had the slowest app launches (54 s) of the five runs. No budget changed except scaling the resume deadline like every other wait.

docs/status.md records this under Known rough edges.

Verification

  • apps/ios/ModexCompanion/Scripts/test-e2e.sh on this commit, iOS 26.5 simulator, on a loaded Mac: 43 tests, 0 failures. The paired flow took 79.5 s, the fixture logged resume requested and then resumed; answering 204 3 ms later, and no stall was logged.
  • pnpm build && pnpm test: 1,613 tests, 0 failures, 16 skipped.
  • The real fixture, driven by a probe acting as the phone, answered /resume in 3–6 ms after 6, 8, 10, 30, 50 and 80 s outages.

Coven-Harness: Claude Code / claude-opus-5-5

The paired iPhone flow failed three times on 2026-10-15/16 (CI runs
38707861067, 38747016392 and 38832248437, attempt 1 each) timing out on
the fixture's /resume. The simulator's unified log in each xcresult
(simctl_diagnostics/<device>/system.logarchive) shows two causes.

The UI-test runner makes no other request, so URLSession's first use in
that process came at this step, minutes after the simulator booted. Its
setup (cfprefsd, nsurlsessiond's storage container, trustd) decided most
of the outcome:

  run                     call to send     reply
  38747016392 a1 (red)    never in 44 s    -
  38707861067 a1 (red)    20 s             none in 8.4 s
  38832248437 a1 (red)    1.3 s            none in 10 s
  38832248437 a2 (green)  0.16 s           204 in 72 ms
  38836144274 a1 (green)  0.08 s           204 in 62 ms

resumeMac now POSTs over a plain BSD socket to 127.0.0.1, which needs
none of those daemons, within the suite's scaled budget. The old 10 s
request timeout was the one wait UITestBudget did not scale.

In 38707861067 and 38832248437 the POST did reach the fixture, which
neither answered nor brought the companion back (the phone kept getting
connection refused), yet exited at once on SIGTERM at the end of the
job. 38848571338 (PR #254) failed the same way at the first reply: the
fixture left a snapshot and then a TLS ClientHello unanswered for 5 s and
8 s, the app marked the Mac disconnected, and the create-thread tap
landed on the disabled button 0.2 s later. Locally the fixture answers
/resume in 3 ms after 8-80 s outages, and dispose() returns at once with
a phone connection in any state. The fixture writes no log, so that cause
stays open. It now logs the phone's calls, the pause and the resume, and
each event-loop stall of 1 s or more with the CPU time, major faults and
context switches during it.

Overall XCTest load did not separate red from green: green 38832248437
attempt 2 had the slowest app launches (54 s) of the five runs.

Coven-Harness: Claude Code / claude-opus-5-5
@vercel

vercel Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
modex Ready Ready Preview Oct 16, 2026 9:47am UTC

Request Review

@github-code-quality

github-code-quality Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: TypeScript

TypeScript / code-coverage-agent

main 9668924 ios-resume-flake cd5eb74 +/-
61% 61% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 16, 2026 10:13 UTC

@BunsDev
BunsDev merged commit ce3dcf5 into main Oct 16, 2026
11 checks passed
@BunsDev
BunsDev deleted the ios-resume-flake branch October 16, 2026 10:14
@BunsDev

BunsDev commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

First failure since this landed, with the new fixture logging. #262's run 38890707807, iPhone companion, failed at CompanionFlowTests.swift:378 in testPairApproveAndFollowUpThroughTheMac:

[fixture 11:05:52Z] event loop stalled 2992 ms: cpu 4 ms, major faults 35, involuntary switches 78, fs reads 0, fs writes 0
[fixture 11:05:56Z] event loop stalled 7176 ms: cpu 25 ms, major faults 228, involuntary switches 416, fs reads 0, fs writes 0
[fixture 11:09:15Z] event loop stalled 2172 ms: cpu 4 ms, major faults 2, involuntary switches 23, fs reads 0, fs writes 0
[fixture 11:09:28Z] event loop stalled 30939 ms: cpu 24 ms, major faults 164, involuntary switches 553, fs reads 0, fs writes 0

The fixture was not busy. Over 30.9 s it used 24 ms of CPU and did no file I/O, but took 164 major page faults and 553 involuntary context switches. It was paged out and waiting to be scheduled. The runner was short of memory while the simulator and XCTest ran, so this is not a bug in the fixture's code. Possible next steps: lower the job's memory use (fewer simulators or runtimes loaded, a smaller simulator device), keep the fixture's working set warm or resident, or let the test wait out a stalled Mac before it taps. A longer budget would only hide it.

Coven-Harness: Claude Code / claude-opus-5-5

BunsDev added a commit that referenced this pull request Oct 18, 2026
* Sample memory during the paired iPhone test in CI

Since #265 the fixture logs every event-loop stall. The two failures since then (runs
38890707807 and 38898248332) were 29-31 s stalls with almost no CPU and 143-164 major page
faults, and their failing steps (lines 378 and 394) are phone-side UI steps that do not
need the Mac. So the whole runner was paging, not just the fixture.

With MODEX_IOS_MEMORY_LOG set, test-e2e.sh now records free memory, swap and the eight
largest processes every 10 s, and prints the lowest-free sample when it exits. CI sets it
inside the uploaded test-results folder, so green and red runs both show what holds the
runner's memory before anyone trims the job.

Coven-Harness: Claude Code / claude-opus-5-5

* Boot the iPhone simulator before the build and sample memory through the job

The first sampled run (39095765816) put the paired test's paging on the simulator's own
first-boot work. Two and a half minutes into the test, six wallpaper poster extensions,
each 260-300 MB, started at once beside News and Fitness widgets, Health and Calendar.
Free memory fell to 28%, swap went from 0 to 942 MB, and the fixture stalled for 38 s. That
run passed only because no assertion was waiting then. The two red runs stalled at the
same point in the test.

The job now picks the simulator and boots it before pnpm install and build, so that work
overlaps the build. A sampler started right after checkout records free memory, swap and
the eight largest processes every 10 s for the whole job, into the uploaded test results.
A last step prints the low point. test-e2e.sh is back to how it was.

Coven-Harness: Claude Code / claude-opus-5-5

* Record what the iPhone job's memory samples showed

Known rough edges: the iPhone /resume entry now names the cause (the simulator's
first-boot burst of wallpaper and widget extensions), the early boot that moves it into the
build, and the two runs since. docs/ios-companion.md says where to look for memory first when
the job fails: the memory.log artifact, the Memory low point step, and the fixture's stall
lines.

Coven-Harness: Claude Code / claude-opus-5-5
BunsDev added a commit that referenced this pull request Oct 18, 2026
Val decided on #290: Known rough edges keeps only open problems. Six fixed
incidents move, word for word, to docs/reviews/2026-10-18-resolved-rough-edges.md,
each under the PR that fixed it (#153, #189, #190, #197, #204, #265 and #271).
The section now links to them.

Entries with an open part stay: the layout e2e note, the demo-thread and sizing
test corrections whose causes are unproven, and the poisoned ChatGPT threads.
Also: node-pty's line says Modex still ships the beta, the demo-thread note no
longer waits on a merge that happened (#189), and the tracker pointers list the
open CF PRs after #289 landed.

Coven-Harness: Claude Code / claude-opus-5-5
BunsDev added a commit that referenced this pull request Oct 18, 2026
…ycle 1) (#292)

* Record what shipped in plans, specs, README and status

Docs and plans steward, cycle 1 (#290).

- Plans: a status line on each ledger under docs/superpowers/plans/ and on
  docs/mac-store-preview-plan.md, naming the PRs and release that delivered it.
  Unticked boxes stay as history rather than being ticked after the fact.
- Specs: routines (Phases 0 and 1 on main), sticky Auto routing (shipped in
  v0.0.11) and approval rules (parts 1 and 2 shipped, gate off).
- README: app-owned sign-in, self-updating Macs from v0.0.12, Windows and Linux
  installers from v0.1.0, Images and Plugins no longer marked unreleased.
- status.md: the site's static fallback follows apps/site/release.json; the
  delivered release-candidates entry leaves In flight for a pointer to tracker
  #273; Next 3 points to #286.

Coven-Harness: Claude Code / claude-opus-5-5

* Bring reference docs in line with main and the releases

Docs and plans steward, cycle 1 (#290). Each change was checked against the
code on main, a release section of status.md or a review.

- Shipped work no longer reads as pending: the approval rules editor (v0.0.7),
  Modex sign-in (v0.0.9), 1Password filling (v0.0.11), the notes folder
  (v0.1.0), the hosted native updater scenarios and the first
  published-to-published upgrade, and Windows/Linux publication.
- Behaviour matches the code: Windows and Linux show no update banner; Auto's
  judge sees a placeholder for assistant replies and runs `jev` with one
  attempt; Claude's model list is Modex's fixed aliases; the Settings sections
  and transport labels; Space options → Agent notes; the companion's policy
  route and current version; the knowledge fence for overlapping folders; CI's
  e2e runs the unpackaged build.
- The Store record and processed 0.0.8 package are recorded under gate 5.

Coven-Harness: Claude Code / claude-opus-5-5

* Close the two finished In flight entries and add the GitHub App to Next

Val decided on #290: the local work recovery and retired worktrees entries
are done, so they leave In flight. The recovery audit and the archive
READMEs keep their record. Their one open item, repository authorization
through a GitHub App, becomes Next 4, ahead of the out-of-scope Cloud tasks.

Coven-Harness: Claude Code / claude-opus-5-5

* Move fixed rough edges into a dated review

Val decided on #290: Known rough edges keeps only open problems. Six fixed
incidents move, word for word, to docs/reviews/2026-10-18-resolved-rough-edges.md,
each under the PR that fixed it (#153, #189, #190, #197, #204, #265 and #271).
The section now links to them.

Entries with an open part stay: the layout e2e note, the demo-thread and sizing
test corrections whose causes are unproven, and the poisoned ChatGPT threads.
Also: node-pty's line says Modex still ships the beta, the demo-thread note no
longer waits on a merge that happened (#189), and the tracker pointers list the
open CF PRs after #289 landed.

Coven-Harness: Claude Code / claude-opus-5-5

* Move status.md's release sections into their release reviews

Val decided on #290: status.md keeps the Shipped table as the index, and each
release's details live in its review. The v0.0.6 to v0.1.0 sections (651 lines)
move unchanged to a "Status summary" section at the end of each review. Only link
targets change, so they resolve from docs/reviews/. status.md drops from 1,060 to
388 lines.

The Shipped rows now link their reviews. Four links that pointed at the old
release anchors now point at the reviews. A new convention and step 1 of the
release procedure say where a release's details go from now on.

Coven-Harness: Claude Code / claude-opus-5-5

* Trim the Mac App Store entry to its current state

Val decided on #290. The 52-line In flight entry becomes 15 lines: what Apple
shows, what signed acceptance covered, and what is open, each linked to its
receipt. The old entry moves unchanged to a "Status summary" section of the
October 11 signed-acceptance review, with links re-based to docs/reviews/.

The short entry drops two statements that no longer hold. The iPhone CI failures
have been diagnosed (resolved rough edges), and the Store recovery changes are
on main (edf52fc, #173).

Coven-Harness: Claude Code / claude-opus-5-5

This branch was successfully deployed

1 active deployment
Preview — cd5eb744 Deployed Oct 16, 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.

1 participant