Repository navigation
mac: accept the compiler's help.replacement shape, so a suggested fix stops killing the preview frame - #488
Merged
Conversation
…ling the frame
The compiler nests a suggested fix's range inside `source`, reusing
`labels[].source` so a fix can name another file:
"replacement":{"source":{"start_byte":5,"end_byte":11,"path":"main.tex"},
"text":"\\alpha"}
Both Swift decoders required a flat `start_byte`/`end_byte` on `replacement`
and read `source` for its path only, so both threw on every diagnostic that
carried a fix. PreviewControllerClient tries FastJSON and falls back to the
reference decoder; with both failing, the update became
`.protocolViolation("preview update: ...")` and the *whole* preview frame was
dropped -- pages and diagnostics together, not just the fix.
Nothing has ever emitted the flat shape. The compiler is the only producer of
`help.replacement`, and its own tests assert the nested spelling. Swift's tests
used hand-written flat fixtures, so each side passed alone and only a
cross-boundary test could see the disagreement -- and those tests skip unless
the Rust binaries are built and pointed at by env var, which is why this sat on
main. With them wired up, five tests fail on this.
Both decoders now take the range from `source` when the flat pair is absent;
the flat pair still wins when both appear, so existing expectations hold. The
contract had never specified `help.replacement` at all, which is the root cause;
it now does, including the precedence rule.
Implementation-Agent: orchestrator-astra
Commit-Executor: orchestrator-astra (direct; Cursor usage limit)
GoKubar
added a commit
that referenced
this pull request
Sep 15, 2026
…#490) The step read run: swift test 2>&1 | tee swift-test.log | grep -vE '^\s*$' | tail -n 400 A `run:` step's default shell is `bash -e`, and a pipeline's exit status is its LAST command's. `tail` always succeeds, so the step returned 0 no matter how many tests failed. `bash -e -c 'false | tee /dev/null | tail -n1'` exits 0; with `set -o pipefail` it exits 1. The mac job has therefore been reporting success over real failures. Gating main on `mac-m1max-a` with the helpers wired in finds 7 failing tests that CI called green (capture acceptance 2, multi-file navigation 2, real-compiler spans 1, output bounds 2). `scripts/ci/build-helpers.sh | tee -a "$GITHUB_ENV"` has the same hole, in both ci.yml and release.yml, and it compounds: a failed helper build is hidden by `tee`, the FLASHTEX_* lines never reach the environment, and the ~126 tests that drive real binaries then XCTSkip. The job goes green having tested none of the Rust/Swift boundary -- which is how the `help.replacement` contract break (#488) survived. The iPad job already wraps both of its piped `xcodebuild` steps in `set -o pipefail`; these three were the ones that missed it. Expect the mac job to go red until those 7 are fixed. That is the point. Implementation-Agent: orchestrator-astra Commit-Executor: orchestrator-astra (direct; Cursor usage limit)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
The compiler nests a suggested fix's range inside
source, reusing thelabels[].sourceshape so a fix can name a file other than the diagnostic's own (crates/compiler/src/diagnostics.rs):Both Swift decoders required a flat
start_byte/end_byteonreplacementand parsedsourcefor its path only, throwing the range away:FastJSON.swift:364—throw error("replacement missing start_byte")RuntimeV1.swift—startByte = try c.decode(Int.self, forKey: .startByte)Why it is worse than a missing fix
PreviewControllerClienttries FastJSON and falls back to the reference decoder. Both throw, so the update becomes.protocolViolation("preview update: ...")and the entire preview frame is discarded — pages and diagnostics together, not just the fix. Any document whose compile produced a did-you-mean would lose its preview update.This is the Tab-to-apply-fix path.
Why it survived on main
Nothing has ever emitted the flat shape. The compiler is the only producer of
help.replacementand its own unit tests assert the nested spelling; Swift's tests used hand-written flat fixtures. Each side was self-consistent, so only a cross-boundary test could see the disagreement — and those testsXCTSkipunless the Rust binaries are built and pointed at by env var:Five of those failures are this bug. The contract never specified
help.replacementat all, which is the root cause.The fix
Both decoders take the range from
sourcewhen the flat pair is absent. The flat pair still wins when both are present, sotestHelpReplacementDecodesBareOrWithPathand every existing expectation are unchanged. A replacement with no range in either place is still rejected — and now only the replacement, per the contract rule added here.docs/contracts/runtime-v1.mdnow specifies the shape, the UTF-8/zero-based/end-exclusive offsets, the precedence rule, and that a consumer must reject an unusable replacement alone rather than the enclosing frame.Tests
testHelpReplacementAcceptsTheCompilersNestedSourceRange— the exact bytesdiagnostics.rsasserts it writes.testNestedReplacementRangeDecodesIdenticallyInBothDecoders— FastJSON and the reference decoder agree on that frame.testFlatReplacementOffsetsWinOverNestedOnes,testReplacementWithNoRangeAtAllIsRejected.Gated on
mac-m1max-awith the Rust binaries wired in.Implementation-Agent: orchestrator-astra
Commit-Executor: orchestrator-astra (direct; Cursor usage limit)