Repository navigation
cmux-rd: one typed app line for cmux rd serve|connect, read back through a C line reader (ABI 5; Mac Screen step A) - #35828
Conversation
…ugh a C line reader (ABI 5) The JSON lines `cmux rd serve` and `cmux rd connect` print for the app had two definitions: json! literals in cmux-rd-host and the Mac Screen's hand decoder (MacScreenRdMessage, MacScreenRdLines). Now there is one: - cmux-rd-proto app_line (feature serde): AppLine and LinePath, the line shape, and LineSplitter, the stdout byte splitter. Golden vectors in tests/vectors/app_lines.json. - cmux-rd-host serve.rs and connect.rs print AppLine values (same fields; key order now follows the struct). - cmux-rd-ffi: CmuxRdLineReader (cmux_rd_line_reader_new, _free, _push, _next) reads stdout bytes into typed CmuxRdLine values, ABI 5. Tests replay the golden vectors through the C ABI. - CmuxNextMacScreenTests (new): the Mac Screen's current Swift decoder reads every golden vector as its `want`, so the Rust reader can replace it with no change for any line the host prints. Step A of the two-step app FFI path: no Swift caller of the new C ABI until the app FFI release that includes it is pinned; step B (the Mac Screen reads lines through CmuxRdLineReader, MacScreenRdMessage and MacScreenRdLines deleted) follows the re-pin.
…ippy E0282 on 1.95)
|
cmux status (one comment, edited in place; each line is updated by the job that owns it) Review App of this head (app.zip, kept 1 day)
red: cmux-next checks (god files, concurrency, crash safety, l10n); no finished base run on 00add02 to compare; do not merge until green; see lane-rules Shipped in:
|
|
Review (independent review subagent): SHIP at c6450d9 Correctness first, then repo rules. Read-only review of What I checked
Findings (none blocking)
|
|
Expected red for the lander: the app FFI pin step of |
|
Found 7 test failures on Blacksmith runners: Failures
|
…ader; the Swift decoder goes (step B of #35828) (#35876) * Mac Screen: read cmux rd serve|connect lines through the Rust line reader; delete the Swift decoder Step B of the two-step app FFI path (step A: the typed AppLine, the C line reader and the golden vectors). MacScreenRdProcess hands stdout bytes to RemoteRdLineReader (CmuxNextRemoteView, over cmux_rd_line_reader_* of cmux-rd-ffi) and yields its typed lines; MacScreenRdMessage (the hand decoder) and MacScreenRdLines (the byte splitter) are deleted. The process keeps only the spawn, the pipes, the stderr tail and the stdin writes. MacScreenRdLineTests now feeds every golden vector through the Rust reader; the Swift decoder passed the same vectors before it was deleted. Needs the CCmuxAppFFI release that includes ABI 5 pinned in Package.swift. * swift-logic table: the Mac Screen's rd line reader wrapper and process plumbing are PLATFORM (cmux_rd_line_reader_*)
![Fix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-light-3x.png)
Summary
First Rust move for the tip's swift-logic red (lead order after 18:00Z; the task was offered to Abdulaziz Albahar in STATUS 12204 first). The Mac Screen's
cmux rd serve|connectstdout lines had two definitions:json!literals in cmux-rd-host and a hand decoder in Swift (MacScreenRdMessage,MacScreenRdLines). This PR makes Rust the only definition and gives the app a C reader for it. It is step A of the two-step app FFI path: no Swift caller of the new C ABI until the app FFI release that includes it is pinned.cmux-rd-protoapp_line(featureserde):AppLineandLinePath, the line shape, andLineSplitter, the stdout byte splitter. Golden vectors:tests/vectors/app_lines.json(every line kind of the old Swift decoder: key, candidate, candidates_done, connected, listening, ended, path with kind and rtt_ms, displays with current, the displays error, plus an unknown line, a non-JSON line and a field of the wrong type).cmux-rd-hostserve.rsandconnect.rsprintAppLinevalues. Same fields; the key order of a line now follows the struct (no reader depends on key order).cmux-rd-ffi:CmuxRdLineReader(cmux_rd_line_reader_new,_free,_push,_next) andCmuxRdLine, ABI 4 -> 5. No I/O, no threads, panics caught, a panic poisons only that reader.CmuxNextMacScreenTests(new test target,MacScreenRdLineTests): the Mac Screen's current Swift decoder reads every golden vector as itswant. That is the behavior-neutral proof: for every line the host prints, the Rust reader gives the Swift code the same values it reads today.Step B (written and on branch
swift-logic/macscreen-rd-lines-b, head 306b582, not in this PR):RemoteRdLineReader(CmuxNextRemoteView, a thin wrapper overcmux_rd_line_reader_*),MacScreenRdProcessreads lines through it,MacScreenRdMessageandMacScreenRdLinesare deleted, andMacScreenRdLineTestsfeeds the vectors through the Rust reader. It opens as its own PR after this PR lands, app-ffi-release.yml publishes the release and the re-pin PR lands. Not in scope:MacScreenRdDocumentandMacScreenRdServers(the cmux.rd/1 offer and answer text format). No Rust code owns that format today, so they stay Swift.Numbers
swift-logic-lines.py, swift_logic_lines (mirror_lines 71,927 everywhere; missing 15, invalid 0):Step B deletes
MacScreenRdMessage(23) andMacScreenRdLines(15).MacScreenRdProcess(105) becomes process plumbing only, and its new row says so with the FFI call (lead rule c). The new wrapperRemoteRdLineReader(80) gets PLATFORM rows like the otherRemoteRd*cmux-rd-ffi wrappers. This move alone does not turn swift-logic green: the tip is +546 over 415,218, and step B gives -143.Changelog
none
Observed / Not run
Observed, fleet steps on c6d9ab7 or c6450d9 (this head):
cmux-ci run --class light --script scripts/ci/feat-parity-check.sh --arg rust-workspace --arg cmux-tui/crates/cmux-rd-ffiat c6d9ab7: step 402081659a6ef2ef5854918f, green. 57 tests, including the 5line_reader_testsandheader_declares_exactly_the_exported_functions_and_codes(the header and the exports agree, with ABI 5).--arg cmux-tui/crates/cmux-app-ffiat c6d9ab7: step 06415966171e0394243cf985, green.cmux-ci run --class light --script scripts/ci/run-swift-testing-suites.sh --arg Packages/macOS/CmuxNext --env CMUX_SWIFT_TEST_SUITES=MacScreenRdLineTestsat c6d9ab7: step 7921ed72ed76c99430274f2a,PASS ^CmuxNextMacScreenTests\.MacScreenRdLineTests/(the old Swift decoder matches every vector).cmux-tui-rust-check.sh --os macos --arg clippyat c6450d9: step a7e9929aa05ac79a0927f3f1, green. The same at c6d9ab7 was red, step 8c236eb2cc562486441cfe49 (E0282 in my splitter test), fixed in c6450d9.cmux-tui-rust-check.sh --os linux --arg fmtat c6d9ab7: step 92f81d99e2d7676f0d6168ed, red on base files only (cmux-app-manifest tests/customize_example.rs, cmux-tui-core apps/grants.rs and lib.rs, cmux-tui link/sync_cli.rs and store.rs). None of them is in this PR; rustfmt --check of the changed files passes with each crate's edition.cmux-tui-rust-check.sh --os macos --arg rd-hostat c6450d9: step 8d10f3568178258dfea4953d, clippy red onmac/capture.rs:247 displays is never used(this lane builds without thelinkfeature, so serve.rs, the only caller, is out). The same lane on base 2d102f8 is red the same way: step c9df8dd88354824c7ba7df84. It is a base finding; rd-host tests pass in both.cmux-tui-rust-check.sh --os linux --arg test --arg app_lineat c6450d9: step 1901370296fb198e25d3ee9f, "no tests to run". On Linux nothing in the cmux-tui workspace turns on cmux-rd-proto'sserdefeature (rd-host is a macOS-only dependency of cmux-tui), soapp_linecompiles out there, ascontrol.rsdoes. The same on macOS: step 231d065bdaf96e7553d39927, green, 5 of 5app_linetests.cmux-ci run --class light --script scripts/cmux-next/build-app-ffi.shat c6450d9: step 9a8bb411b755274ed000e890, green (CCmuxAppFFI.xcframework builds with ABI 5).python3 scripts/cmux-next/prepush-gate.py: no new violations.Not run: no build of the app with the new ABI (step B needs the published release). No GUI run of a Mac Screen session (no line shape changes: the vectors prove the values).
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Summary by cubic
Makes Rust the single source of the JSON lines
cmux rd serve|connectprint for the app, and adds a C line reader (CmuxRdLineReader, ABI 4→5) so the app reads them back as typed lines. The line shape was previously defined twice —json!literals incmux-rd-hostand a hand decoder in Swift — and nowcmux-rd-proto'sapp_lineowns it; the host printsAppLineand the Swift Mac Screen reads the same values as today. A new Swift test target proves the existing decoder reads every golden vector as itswant, so the behavior is unchanged.app_linemodule (featureserde):AppLine,LinePath,LineSplitter, and golden vectors for every line kind the Swift decoder knew, plus unknown, non-JSON, and wrong-type lines.cmux-rd-ffireader:cmux_rd_line_reader_new/_free/_push/_next, no I/O or threads, panics caught per reader.serve.rs/connect.rsprintAppLinevalues; same fields, key order now follows the struct.MacScreenRdMessage/MacScreenRdLinesdeleted) lands after the re-pin.Written for commit c6450d9. Summary will update on new commits.