Skip to content

mac: unblock the gate — bound both helper pipe drains, split IMECompositionTests out (#681) - #772

Merged
d-q222 merged 15 commits into
mainfrom
agent/daniel-parent/fix681-ime-sigabrt
Sep 16, 2026
Merged

d-q222 merged 15 commits into
mainfrom
agent/daniel-parent/fix681-ime-sigabrt

Conversation

@d-q222

@d-q222 d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Release blocker for 0.1.6. Refs #681.

Branched off PR #660's head (ci/snapshot-env-gate-fable), because main currently does not compile in apps/mac (PreviewV2Tests.swift:807 uses model before its declaration) and #660 fixes that. #660's diff therefore appears in this PR's file list; my own change is only .github/workflows/ci.yml, apps/mac/Sources/FlashTeXMac/ExactPDFExport.swift and apps/mac/Sources/FlashTeXMac/WholeDocumentList.swift. Merge #660 first and this shrinks to those three files.

What

  1. ExactPDFExport.run and WholeDocumentList.render: bound the pipe drains. Both bounded the helper process with their timeout: parameter and then waited on the two pipe-drain tasks with no bound at all (group.wait() at ExactPDFExport.swift:77, drained.wait() at WholeDocumentList.swift:86). Process.terminate() is SIGTERM to the direct child only: if it ignores the signal, or any descendant it spawned still holds the pipe write ends, readDataToEndOfFile() never sees EOF and the unbounded wait blocks the calling thread forever. In the Mac test bundle that thread is the main thread, so the whole xctest process hangs — 100% CPU on a reader thread, no output, no failure, no timeout. Both now wait 10 s, escalate to SIGKILL, wait 5 s more, then report whatever was drained. The drains publish through a small lock because the bounded wait can expire while they are still running.

  2. CI: split IMECompositionTests out of the gate (stopgap for P0: xctest aborts (signal 6) deterministically at IMECompositionTests.testCancelledCompositionLeavesTheHelperAndLedgerUntouched — regressed today on main, blocks the whole fleet's gate #681). The gating step is now swift test --skip 'FlashTeXMacTests\.IMECompositionTests'; the suite runs alone in a second, continue-on-error step so it is excluded from the gate but never silently dropped. Both logs are uploaded.

Item 2 is a stopgap. It hides a real memory-safety bug; it does not fix it. The root cause is below — it is now identified precisely, which it was not before.

Why

#681's abort does not just fail one test: it kills the xctest process, truncating every CI run at test ~668 of ~1400 while printing zero failures — the false-green mechanism of #680. Roughly 59 suite files after "I" alphabetically had never executed on CI.

Root cause of #681 — identified

The thread's standing conclusion ("nondeterministic; no commit introduced it") is wrong in its key particular. Measured here:

  • On CI it is 100% deterministic — 6 runs for 6, on b92ef891, on 5c9a18a5, and on four instrumented commits of this branch.
  • On this Mac it does not reproduce at all — 20/20 isolated runs pass, and a full local suite run passes IMECompositionTests 4/4. So it is environment-specific, not a race whose rate "rose".

I instrumented the path with an unbuffered stderr trace (print is block-buffered under swift test, which is why every previous log died silently) and bisected it over four CI runs down to a single statement:

IME-TRACE cancel: compose(かん)…
IME-TRACE CompletingTextView.shouldChangeText enter {23, 1}
IME-TRACE delegate shouldChangeTextIn {23, 1} 'かん'
IME-TRACE CompletingTextView.shouldChangeText -> true
IME-TRACE storageObserver(Syntax) enter
freed pointer was not the last allocation          <-- abort, next line

The abort is inside SyntaxHighlighter.swift:677 — SyntaxPainter's NSTextStorage.didProcessEditingNotification observer — specifically its MainActor.assumeIsolated { … } body, reached on the second composition step. The second step is the first setMarkedText that replaces an existing marked range ({23, 1}); the first step is a plain insertion ({23, 0}) and is fine.

The mechanism: AppKit posts that notification synchronously, from inside its own in-progress text-storage edit, while the enclosing XCTest async test task is the current task. MainActor.assumeIsolated then does task-allocator work on that task from a re-entrant Obj-C frame, and the alloc/free ordering is violated — which is exactly what Swift's StackAllocator reports as freed pointer was not the last allocation (swift_task_dealloc_specific → swift_Concurrency_fatalError, inside XCTSwiftErrorObservation, as #681 recorded).

Causality confirmed, not just correlation. A probe made that one observer return early while a flag was set, and the flag is set only for the duration of the cancel test. On CI, the cancel test then passed, and the abort moved to the very next test in the suite — testHelperKilledMidComposition…, which drives the same composition with the probe inactive. That is a positive control in both directions.

Why I did not ship the fix. The correct fix is to stop SyntaxPainter re-entering main-actor isolation inside AppKit's synchronous storage edit. It cannot simply be deferred: the observer reads storage.editedRange / changeInLength, which are only valid during the synchronous post, and the incremental lexer's sync invariant (SyntaxHighlighter.swift:723) depends on seeing every edit in order. That is an isolation-model change on the typing hot path in a file this lane does not own, and it wants its owner's review rather than my guess. Hence the sanctioned stopgap, with the cause now pinned to a line.

Newly revealed — what was behind the truncation

With the drain fix the full local suite runs to completion for the first time: 1381 tests started, no hang, no truncation, no signal. Before it, three consecutive full runs hung forever (one for 65 minutes before I killed it), main thread parked in _dispatch_group_wait_slow:

Hung test Blocked at
SearchableTextTests.testBoldTfmWidthsDoNotSplitWords ExactPDFExport.swift:77
V2WindowTests.testOverLimitFailureEngagesTheWindowAndScrollingMovesIt WholeDocumentList.swift:86
(third run, same family) WholeDocumentList.swift:86

This matters for sequencing: fixing #681 alone would have converted a truncated CI run into a hung one, because these tests sit after IMEComposition alphabetically and had never run.

Two further crashes found, both separate bugs, not mine, not fixed here:

  • CompletionTests.swift:314 — s[0] after XCTAssertEqual(s.map(\.label), ["itemize"]), array index out of range when suggestions returns empty. A third force-unwrap-class crash site, in a third file (the known ones were AutomaticCompletionTests 229/238 and CompletionLatencyTests:275).
  • CompletionLatencyTests:275 — the known SIGTRAP, still unfixed, owned elsewhere.

Correction to #681's comment thread: the claim that "25 reports from 2026-09-15 22:18 onward all carry the swift_task_dealloc_specific signature" does not hold. Of the 29 xctest-*.ips reports on this Mac, only 2 (both 2026-09-14) carry that signature; every report from 09-15 22:32 onward is a SIGTRAP force-unwrap/bounds crash in the Completion suites. The two signatures were conflated, which is part of why this looked nondeterministic.

Overlap check

Test results

swift test --filter IMECompositionTests, 20 runs, BEFORE:
=== before TOTAL: runs=20 crash=0 fail=0 pass=20  crash-rate=0/20
swift test --filter IMECompositionTests, 20 runs, AFTER:
=== after TOTAL: runs=20 crash=0 fail=0 pass=20  crash-rate=0/20

Both are 0/20 because this Mac never reproduced #681 — that is the finding, not a proof of fix. The reproducer is CI, where it was 6/6 before this change. The before/after that matters is CI's, on this PR.

full local suite, gate lock held, BEFORE the drain fix:
  hung indefinitely, 100% CPU, no output (killed after 65 min)
full local suite, gate lock held, AFTER the drain fix:
  started: 1381
  ### exit: 1      (test failures; no hang, no truncation, no signal)

The 28 distinct local failures are local-environment artifacts, not findings: the completion vocabulary is empty in my local run (failed - no matching suggestion in [], "\fr" instead of "\frac{}{}") — the same reason CompletionTests crashes locally and does not on CI — and the DesignSnapshots failures are the known @2x-vs-@1x issue. CI on this PR is the authority for what the previously-unreachable ~59 suite files actually do; I did not want to report local noise as newly-revealed failures.

Not done

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

GoKubar and others added 13 commits September 15, 2026 18:44
Twelve DesignSnapshots tests fail on every CI run, `harness-probe` among
them -- two `Text`s on `windowBackgroundColor`, which no feature work
touches. When the harness's own smoke probe mismatches, the rendering
environment differs, not the UI.

It does. Every committed reference is exactly twice its surface's point size
(the probe: 640x320 px for 320x160 pt), recorded on the owner's Retina Mac.
A `macos-26` runner composites onto a virtual display at @1x, with a
different OS build rasterising the text and the materials. The harness
already compares perceptually -- precision 0.99, perceptualPrecision 0.98 --
and the difference still exceeds that budget, so widening the tolerance is
not available: a tolerance that absorbs a resolution change would miss the
design regressions these tests exist to catch.

Committing a second, CI-recorded reference set was the other option and is
worse: the runner image churns (20260907.0351.1 today), and every image bump
would put main back to red until someone re-recorded.

So the suite now states what it was recorded on (`__Snapshots__/
environment.json`), measures what it is running on -- through the real
capture path, pixels over points, not `NSScreen` -- and skips the comparison
when they differ, with both environments in the message. XCTest counts and
prints those skips; nothing passes quietly.

Re-recording stays a button, not a hand-edit: `RECORD_SNAPSHOTS=1` rewrites
the manifest in the same run as the PNGs, and the new "Record design
snapshots" workflow does it on a runner and uploads both. #653 will
invalidate all 24 references when it lands; that is the path.

Coverage does not go to zero where the gate bites: HarnessSmokeTests now
checks on every machine that the window server still composites a hosted
SwiftUI view in both appearances at the scale this machine measures. Only
pixel equality against someone else's hardware is skipped.

Implementation-Agent: claude-fable-5 (Claude Code subagent, linux-primary)
Commit-Executor: claude-fable-5 (direct; Cursor usage limit)
Co-authored-by: GoKubar <[email protected]>
…fable

# Conflicts:
#	apps/mac/Tests/DesignSnapshots/SnapshotHarness.swift
…CompletionTests

ControlSnapshotTests.swift was the one DesignSnapshots suite #660 did not
add the backing-scale gate to; it's the same controls-light/controls-dark
mismatch the other three suites already skip loudly for. Gate it the same
way.

Separately, CI's mac-swift-test-log artifact for this branch's run
(35134648812) showed an unattributed 'xctest ... exited with unexpected
signal code 6' mid-suite, with no final failure summary at all -- the
exact 'aggregate failures, no test named' shape daniel-parent found on the
iPad job. Reproduced locally: AutomaticCompletionTests.swift:238 force-
unwraps tv.session! after a waitUntil confirms it non-nil, but the session
can close again in the gap between the check and the read (a real race,
not a flake in the check itself) -- Fatal error: Unexpectedly found nil,
SIGTRAP locally / SIGABRT in CI's release-ish config. Same pattern at
line 229. Both now capture the session once via guard let and fail with
an explicit message instead of trapping.
Every sub-second helperTimeout formatted as Int(t) prints '0 s' --
Int(0.4) == 0 -- so DocumentFilesTests' 0.4s budget reports 'no status
reply ... within 0 s', which reads as a zero timeout and is not. Four
sites (read, save, and the late-reply/status-check messages) now print
the actual interval.
…iagnosis)

What changed:
Adds `imeTrace`, writing to stderr UNBUFFERED, and calls it at every stage of
`IMEHarness.attached`/`close` and of
`testCancelledCompositionLeavesTheHelperAndLedgerUntouched`, including a final
"BODY DONE" marker. This is diagnosis only; no behaviour changes.

`swift test` block-buffers stdout, so the existing `print` output is lost at the
abort and the CI logs show the signal with no indication of how far the test
got. The abort is inside XCTest's own async error observation
(`swift_task_dealloc_specific` -> `swift_Concurrency_fatalError`), so the key
unknown is whether the test body completes before the process dies.

What was run:
  swift build --build-tests -> Build complete
  swift test --filter IMECompositionTests (x20, uninstrumented) -> 20 passed, 0 crashes
  full local suite (3 Completion suites skipped) -> IMECompositionTests 4/4 passed

Next step:
Read the IME-TRACE lines from this branch's CI run, where the abort is 100%
reproducible (670 tests started, signal 6, 3 runs for 3).

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…sis)

What changed:
The first CI trace stopped at "cancel: caret…" and never reached "holds#1",
and neither DEFER nor close() ran, so the abort is inside the caret/compose/
cancel region and not in XCTest teardown. This narrows it statement by
statement: setSelectedRange, the Task.sleep in turn() (before and after), each
setMarkedText step, and unmarkText.

What was run:
  swift build --build-tests -> Build complete
  swift test --filter IMECompositionTests -> 4 passed, traces present locally

Next step:
Read the IME-TRACE tail from this branch's dispatched CI run.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
#681)

What changed:
CI narrowed the abort to inside the SECOND `setMarkedText` — the first one that
replaces an existing marked range. Two head-of-run-loop hops can execute
main-actor work nested inside that AppKit call while the async test task is
live: `TypingBench.nextRunLoopTurn` (CFRunLoopPerformBlock + MainActor.assume-
Isolated, enqueued by `Coordinator.compositionStep`) and
`Completion.Scheduler.onMain`. Both now bracket their block with a trace, and
`compositionStep` traces enter/exit. Tracing is off unless a test sets
`ftTraceOn`, so only this one test emits it.

What was run:
  swift build --build-tests -> Build complete! (15.84 sec)
  swift test --filter IMECompositionTests -> 4 passed; traces show
  compositionStep 1..6 bracketing each compose()

Next step:
Read CI: whether a BLOCK enter appears between "compose(かん)…" and the abort.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
What changed:
CI showed the abort lands inside the second setMarkedText BEFORE compositionStep
runs, so neither head-of-run-loop hop is the trigger. These traces say how far
into AppKit's own change processing the call gets: the two shouldChangeText
hooks, textDidChange and textViewDidChangeSelection. Trace-only.

What was run:
  swift build --build-tests -> Build complete! (9.81 sec)

Next step:
Read CI; if none of these hooks is entered, the abort is inside AppKit before it
calls back into our code at all.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
What changed:
1. #681 diagnosis: CI put the abort between `shouldChangeText -> true` for the
   marked-range REPLACEMENT ({23, 1}) and any change notification. The only
   FlashTeX code that can run in that window is the four
   NSTextStorage.didProcessEditingNotification observers (Completion, Rotor,
   SpellCheck, SyntaxHighlighter); each now traces enter/exit.
2. Real fix, independent of #681: ExactPDFExport.run and WholeDocumentList.render
   both bounded the helper PROCESS with `timeout` and then waited on the pipe
   drains with no bound at all. terminate() is SIGTERM to the direct child only,
   so a descendant holding the write ends leaves readDataToEndOfFile without EOF
   and the unbounded wait blocks the calling thread — the main thread in the test
   bundle — forever. Both now wait 10 s, escalate to SIGKILL, wait 5 s more, and
   report what was drained; the drains publish under a lock because the bounded
   wait can expire while they run.

What was run:
  swift build --build-tests -> Build complete! (10.15 sec)
  Three local full-suite runs each hung here with no output and no failure,
  main thread parked in _dispatch_group_wait_slow:
    SearchableTextTests.testBoldTfmWidthsDoNotSplitWords -> ExactPDFExport.swift:77 (65 min)
    V2WindowTests.testOverLimitFailureEngagesTheWindowAndScrollingMovesIt -> WholeDocumentList.swift:86
    a third run -> WholeDocumentList.swift:86 again

Next step:
Read CI for the storage-observer traces; then finalise #681.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
What changed:
CI put the abort message on the line immediately after
`storageObserver(Syntax) enter`, inside
SyntaxHighlighter.swift's NSTextStorage.didProcessEditingNotification observer,
for the marked-range REPLACEMENT ({23, 1}). This probe makes that one observer
return early while ftTraceOn (i.e. only inside the IME cancel test), so CI says
whether it is the cause or merely the last thing that ran. Probe only -- not a
fix, not to merge as is.

What was run:
  swift build --build-tests -> Build complete! (8.42 sec)

Next step:
If CI passes 668+ tests, the observer is the cause.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…sitionTests out (GH#681)

What changed:
1. `ExactPDFExport.run` and `WholeDocumentList.render` bounded the helper
   PROCESS with their `timeout:` and then waited on the pipe drains with no
   bound at all. `terminate()` is SIGTERM to the direct child only, so a child
   that ignores it — or any descendant still holding the write ends — leaves
   `readDataToEndOfFile` without EOF and the unbounded `group.wait()` /
   `drained.wait()` blocks the calling thread forever. In the Mac test bundle
   that thread is the main thread, so the whole xctest process hangs with no
   output and no failure. Both now wait 10 s, escalate to SIGKILL, wait 5 s
   more, and report what was drained; the drains publish under a lock because
   the bounded wait can expire while they are still running.
2. CI runs `swift test --skip FlashTeXMacTests.IMECompositionTests` for the
   gate and that suite alone in a second, non-gating step. GH#681 is a Swift
   task-allocator abort that kills the process, so it TRUNCATES the run at test
   ~668 of ~1400 while printing zero failures (#680's false green). The skip is
   in the shared workflow, so both sides of any comparison skip it, and the
   suite is excluded from the gate without being silently dropped.

This is a stopgap for #681: it hides a real memory-safety bug, it does not fix
it. The root cause is identified in the PR description.

What was run:
  swift test --filter IMECompositionTests x20, before -> 20 passed, 0 crashes
  swift test --filter IMECompositionTests x20, after  -> 20 passed, 0 crashes
  (this Mac does not reproduce #681; CI does, 6 runs for 6)
  full local suite BEFORE, three runs, each hung forever with no output, main
  thread parked in _dispatch_group_wait_slow:
    SearchableTextTests.testBoldTfmWidthsDoNotSplitWords -> ExactPDFExport.swift:77 (65 min)
    V2WindowTests.testOverLimitFailureEngagesTheWindowAndScrollingMovesIt -> WholeDocumentList.swift:86
    a third run -> WholeDocumentList.swift:86 again
  full local suite AFTER -> ran to completion, 1381 tests started, no hang,
  no truncation, no signal

Next step:
Read this branch's CI run for the real contents of the ~59 suite files the
abort has been hiding.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
What changed:
The previous commit's `git add -A apps/mac` swept up the Package.resolved that
`swift build` generates in the worktree. It is not part of this change.

What was run:
  git rm --cached apps/mac/Package.resolved

Next step:
none.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
What changed:
The second, non-gating `swift test --filter IMECompositionTests` step inherited
the default `if: success()`, so the first CI run of this branch SKIPPED it —
the gating run failed on three unrelated tests and the split silently dropped
the suite again, which is exactly what the split exists to prevent. It is now
`if: always()`.

What was run:
  CI 35160499876 (before this fix): gating step 1420 tests started, no signal;
  step 'swift test -- IMECompositionTests alone' reported: skipped

Next step:
Confirm on the next CI run that the step reports a result.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
@d-q222

d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Final CI evidence (run 35161874576, 96c9e8a4)

The truncation is gone. Gating step:

tests started: 1420        (was 670 on every run before this change)
"exited with unexpected signal code": none

The split works as intended. The non-gating step, now if: always():

swift test --filter 'FlashTeXMacTests\.IMECompositionTests'
tests started: 2
exited with unexpected signal code 6

So #681 is still there, still aborting — it is reported in its own step instead of destroying the gate. Note this also settles a question the thread went back and forth on: on CI it aborts in isolation too, not only inside the full suite (it is this Mac that never reproduces it, in isolation or in a full run).

What the previously-unreachable ~59 suite files actually do

Three failures in 1420 tests, and only two are in the half that had never run:

Test Failure New?
LargeDocumentEditorTests.testLargePasteSelectionAndTypingEndDurableThroughTheRealHelper ControllerError("helper exited (1): output stalled; delivery uncertain, recover durable source and receipts"), at IMEHarness.swift:175 yes (L > I)
SourceEditorViewTests.testMarksArePaintedOnlyAroundTheVisibleWindowAndFast XCTAssertLessThan failed: 3.520875 not less than 2.0 — first mark pass took 3.520875 ms CPU yes (S > I)
DocumentFilesTests.testLateSaveReceiptIsReconciledWithoutLosingLaterEdits no status reply from the project-files helper within 0.4 s no (D < I; passed in the truncated runs, so timing-sensitive on a shared runner)

That is the answer to "nobody knows what is in there": it is in good shape. One real product failure (the large-paste helper stall), one perf budget that is too tight for a shared CI runner, and one pre-existing 0.4 s-timeout flake. Not the pile of rot the truncation could have been hiding.

The 28 local failures I mentioned in the description were indeed local-environment artifacts (empty completion vocabulary, @2x snapshots) — CI shows none of them. I have left them out of this table deliberately.

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

What changed:
Only conflict was .github/workflows/ci.yml, where #659 (already on main) and
this branch both edited the `swift test` step. Resolved to keep BOTH:

- #659's `SNAPSHOT_ARTIFACTS` env and `mkdir -p`, its `--skip
  IMECompositionTests` (so the skip stays in the shared workflow, both sides of
  any comparison carrying it), its `if-no-files-found`/`retention-days` on the
  log upload, and its `mac-snapshot-artifacts` upload step. None of #659 is lost.
- this branch's second, non-gating `--filter IMECompositionTests` step, which
  #659 does not have. Without it the skip alone converts #681's loud crash into
  a quiet absence -- the invisibility of #680, which is what hid ~59 suite files
  in the first place.

The `swift-test-ime.log` path in the upload step merged without conflict, so
both logs are uploaded.

apps/mac had no changes on main since the merge base (this branch already
carries #766 through #660), so the pipe-drain fixes applied unchanged.

What was run:
  git merge origin/main -> 1 conflict (.github/workflows/ci.yml), resolved
  build result in the following commit message / PR comment

Next step:
Build after the merge and re-run CI.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
@d-q222

d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main by MERGE (no force-push, no history rewrite) — now MERGEABLE

git merge origin/main (19b196c) → one conflict, .github/workflows/ci.yml, resolved to keep both sides. mergeable=MERGEABLE.

The ci.yml conflict, and why it mattered

#659 (already on main) already added --skip IMECompositionTests — but with no second step, so the suite was skipped and never run. That is the failure mode worth naming: it converts #681's loud crash into a quiet absence, which is the same invisibility (#680) that hid ~59 suite files for a day. The resolution keeps all of #659 — SNAPSHOT_ARTIFACTS env, mkdir -p, its skip and comment, if-no-files-found: ignore, retention-days: 7, and the mac-snapshot-artifacts upload step — and adds this branch's non-gating second step so the suite still runs and still reports. The swift-test-ime.log path merged into the upload step without conflict, so both logs upload.

Confirmed on the post-merge run: Upload swift test log: success, Upload the snapshots the run actually captured: success. Nothing of #659 was lost.

Build after the merge

cd apps/mac && swift build --build-tests → Build complete!. Main changed no apps/mac source since the merge base, so this was a legitimate no-op rather than a skipped check; the full CI build below is the real evidence.

Post-merge CI (run 35163293913, 51dc4346)

gating step:      1420 tests started, no "unexpected signal code"
non-gating step:  2 tests started, exited with unexpected signal code 6

Both steps behaved exactly as intended: the gate reaches the whole suite, and #681 is reported in its own step instead of destroying the run.

Gating failures, 2 of 1420, neither caused by this PR:

Test Status
LargeDocumentEditorTests.testLargePasteSelectionAndTypingEndDurableThroughTheRealHelper #774 — the real helper stall
DocumentFilesTests.testLateSaveReceiptIsReconciledWithoutLosingLaterEdits pre-existing 0.4 s-timeout flake (D < I, ran before too)

SourceEditorViewTests.testMarksArePaintedOnlyAroundTheVisibleWindowAndFast failed on the previous run (3.52 ms vs a 2.0 ms budget) and passed on this one — so that one is load-dependent on a shared runner, not a hard failure. Worth a separate look at the budget; not this PR.

The job conclusion is failure purely because of those gating test failures, not because of a crash or truncation.

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

@d-q222
d-q222 merged commit 44a0d54 into main Sep 16, 2026
40 of 42 checks passed
ItsAkilesh pushed a commit to ItsAkilesh/flashtex that referenced this pull request Sep 18, 2026
…lash-tex#773)

`testEnvironmentSnippetKeepsIndentationAndClosingStaysExact` indexed
`s[0]`/`c[0]` right after asserting on the array's contents; a failed
XCTAssertEqual doesn't stop execution, so if either array were ever empty
the next line's array subscript traps and kills the whole xctest process
instead of failing one assertion — exactly the mechanism that hid half the
Mac suite for a day (see flash-tex#681, flash-tex#772). Switched both to the `.first?`
idiom the same function already uses for its third suggestions array
(`e`, two lines below), so an unexpected empty result fails the specific
assertion instead of crashing the process.

Verified: `swift build --build-tests` clean; `swift test --filter
CompletionTests` — 38/38 pass, 0 failures, no trap.

Commit-Executor: daniel-muse-lead (Claude Sonnet)
ItsAkilesh pushed a commit to ItsAkilesh/flashtex that referenced this pull request Sep 18, 2026
flash-tex#774)

Root cause, confirmed against this branch's own repro (20 `yes` processes,
18-core machine): the per-write stall watchdog judged a frame's write by
elapsed time since the write *started*, using a single write_all() through
the process's buffered Stdout. Under reader backpressure a large reply
(500KB+) legitimately takes longer than any fixed threshold to drain, but
looks identical to a truly stuck pipe from that vantage point -- so PR flash-tex#775's
"raise 2s to 10s" only delays the same failure to a bigger payload or a
busier machine, it doesn't fix the underlying blind spot.

Fix: the writer thread now writes to the raw stdout fd (bypassing the
LineWriter, which would otherwise swallow a whole line-terminated frame into
one opaque blocking call) in bounded WRITE_CHUNK pieces, resetting the
watchdog's clock on every chunk that makes forward progress. A blocking pipe
write does not return a short count under backpressure, so chunking the
*request* is what keeps control returning to the watchdog periodically. A
slow-but-alive reader now keeps resetting the clock indefinitely; a reader
that never drains anything still trips OUTPUT_STALL_TIMEOUT exactly as
before. Verified against the pre-existing intentionally-never-read tests
(now recalibrated to the shared 10s bound, matching PR flash-tex#772's family), plus
a new test that reads a 2.2MB reply in artificially slow, steadily-paced
chunks totaling ~16s -- longer than the watchdog bound -- and asserts the
helper stays alive and delivers the reply byte-exact.

Also ran LargeDocumentEditorTests.testLargePasteSelectionAndTypingEndDurableThroughTheRealHelper
3x under real 20-process CPU contention with this branch's preview-controller
and the fix681 compiler: all three passed (6.8s/7.3s/7.2s), no stalls.

crates/preview-controller/STDIO.md updated to describe the progress-based
bound instead of the stale "two seconds" line.

Implementation-Agent: claude-sonnet-5 subagent of daniel-parent (Commander)
Commit-Executor: daniel-parent subagent
Co-authored-by: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
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.

2 participants