Skip to content

mac tests: capture acceptance asserts the caret-aware contract it actually has - #491

Merged
GoKubar merged 2 commits into
mainfrom
agent/kabir-claude/capture-acceptance-staleness
Sep 15, 2026
Merged

GoKubar merged 2 commits into
mainfrom
agent/kabir-claude/capture-acceptance-staleness

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Two expectations in CaptureAcceptanceTests predate the caret-context work and fail against the real bridge and preview controller.

1. The advertised destination carries caret context

XCTAssertEqual(session.destination, .init(destinationId: …, projectId: …, path: …, baseRevision: …))

announcedNearbyDestination attaches caret_context whenever the destination's document is open here — that is what lets the companion say "display math" or "already inside $…$" before you send. It is independent of the fluid-caret-pin switch this suite turns off in setUp, so the override does not suppress it.

Now asserted field by field. The wire contract is additive ("consumers must tolerate their absence and unknown values"), so a whole-value comparison fails on every new optional field rather than on a real change.

2. A capture is normalised for its caret

XCTAssertEqual(pending.text, Insertion.insertionText(proposal.latex, into: before, atByte: 17))

approveProposal calls Insertion.captureInsertion, which the source says is "separate from insertionText on purpose": it runs CaretContext.normalize first and only adds surrounding newlines for a display wrap.

The document is \begin{document}\nHello durable world.\n\end{document}\n and the caret is byte 17 — the start of the line holding the prose. So the caret is inline text, and the sample's

\begin{equation}
  \int_0^1 x^2 \, dx = \frac{1}{3}
\end{equation}

is correctly rewritten to $\int_0^1 x^2 \, dx = \frac{1}{3}$. Display there would split the sentence — which is exactly the case captureInsertion exists to handle.

Asserted against captureInsertion now, so the test tracks the path the model actually takes.

Why this sat on main

Both tests XCTSkip without FLASHTEX_BRIDGE / FLASHTEX_PREVIEW_CONTROLLER. Gated on mac-m1max-a with the helpers wired in: main is 13 failures across 7 tests, and these are 2 of them.

Implementation-Agent: orchestrator-astra
Commit-Executor: orchestrator-astra (direct; Cursor usage limit)

…ually has

Two expectations in CaptureAcceptanceTests predate the caret-context work and
fail against the real bridge and preview controller.

`session.destination` was compared with a rebuilt `Destination` carrying only
the four identity fields. The announced destination also carries
`caret_context` -- what the companion shows before sending -- which
`announcedNearbyDestination` attaches whenever the document is open here,
independent of the fluid-caret-pin switch the suite turns off in setUp. Now
asserted field by field: the wire contract is additive, so a whole-value
comparison fails on every new optional field rather than on a real change.

`pending.text` was compared with `Insertion.insertionText`. A capture goes
through `Insertion.captureInsertion`, which is "separate from insertionText on
purpose" (its own doc comment): it runs `CaretContext.normalize` first and only
lays out newlines for a display wrap. Byte 17 is the start of the line holding
"Hello durable world.", so the caret is inline text and the sample's
`\begin{equation}` is legitimately rewritten to `$…$` -- display would split
the sentence.

Both only run with FLASHTEX_BRIDGE / FLASHTEX_PREVIEW_CONTROLLER set.

Implementation-Agent: orchestrator-astra
Commit-Executor: orchestrator-astra (direct; Cursor usage limit)
@GoKubar
GoKubar merged commit d19f16a into main Sep 15, 2026
21 checks passed
GoKubar added a commit that referenced this pull request Sep 15, 2026
…n_launch (#632)

The CI job `rust bridge (ubuntu-latest)` intermittently failed
compiler_process_success_and_timeout_leave_editor_unchanged with
"validation_launch: Could not launch the configured FlashTeX compiler"
on unrelated PRs (#264, #284, #491).

Root cause, reproduced locally: the classic fork/exec ETXTBSY race.
The bridge integration tests run in parallel threads, and each writes a
fresh fake-compiler script (fs::write + chmod) before validate() spawns
it. If another thread forks a child while the writer's fd is still open,
that child inherits the write fd until its own exec; exec'ing the script
in the meantime fails with os error 26 (Text file busy) even though the
writer already closed the file. A standalone stress harness reproduced
605 ETXTBSY failures in 24000 write+spawn cycles across 8 threads, and
the same fake()+validate() pattern against the unfixed crate reproduced
the exact CI error 8 times in 3200 cycles.

Fix in CompilerValidator::validate:
- retry the spawn (up to 20 x 10ms) when the error kind is
  ExecutableFileBusy - the condition is transient by definition and
  clears as soon as the interfering child execs;
- on real launch failure, include the executable path and the
  underlying io::Error in the validation_launch message instead of
  discarding it, so a future failure is diagnosable from the CI log.

The test itself is unchanged, so nothing it asserts is weakened.
Verified: full bridge suite green (170 passed, 0 failed, 2 ignored);
proposal_validation run 20x in a loop, 20/20 green; stress harness
0 failures in 3200 concurrent validate() cycles with the fix vs 8
without it.

Implementation-Agent: fable-bridge-flake
Commit-Executor: fable-bridge-flake (direct; Cursor usage limit)
@GoKubar
GoKubar deleted the agent/kabir-claude/capture-acceptance-staleness branch September 16, 2026 04:17
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