Skip to content

fix(async): support published modules across MoonBit channels - #534

Draft
tonyfettes wants to merge 14 commits into
mainfrom
claude/moonbit-0-10-21-fc5710
Draft

tonyfettes wants to merge 14 commits into
mainfrom
claude/moonbit-0-10-21-fc5710

Conversation

@tonyfettes

@tonyfettes tonyfettes commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

OpenSeek's native host and several independently published Proton modules encounter removed async APIs on the pre-release toolchain. Keep all 24 published modules compatible with the current latest and pre-release channels, without raising Proton's toolchain requirement or changing public APIs.

The compatibility changes cover:

  • Create the power monitor's Linux completion pipe in C and wrap its read end with the shared RawFdStream API. Preserve the readiness/teardown protocol, close the original write descriptor on every exit, and protect read-descriptor ownership transfer from cancellation.

  • Require the published tonyfettes/xlog@0.5.1, whose explicit public method exports support the newer compiler. Its transitive moonbitlang/x@0.5.7 also builds on latest; consumers can keep their existing lower xlog version requirements.

  • Match the configuration platform with a fallback that works with both the old enum and the new non-exhaustive enum.

  • Use the shared ClientConnection request API for updater streaming, preserving encoded paths and queries, redirect limits, connection cleanup, and body-size limits. Adapt the two existing streaming test fixtures to the shared TCP API; no new tests are added.

  • Keep the Mach-O scanner's positioned reads on the versioned moonbitlang/async@0.22.7 filesystem API. The two bundled core versions have different positioned-read APIs; the versioned dependency preserves bounded reads on native and Wasm. Adapt the existing fixture directory setup to the same API.

  • Replace deprecated backslash escapes in interpolated NSIS templates with explicit character interpolation. Existing installer-script expectations remain unchanged.

  • Keep the CLI development server probe on the versioned moonbitlang/async@0.22.7 socket API, retaining hostname resolution and the existing port representation across both compiler channels.

  • Use shared HTTP connection APIs in CDP discovery and network extensions, retaining streaming downloads and GET body behavior. Adapt three existing CDP transport tests to Addr::to_string() instead of the changed port accessor.

  • Preserve the filesystem extension's sync_timestamp option using explicit open/read/sync/close operations.

  • Handle the non-exhaustive platform enum in shell operations while retaining the existing behavior for Linux, macOS, and Windows.

CI and publication continue to use latest. Public generated interfaces, templates, and release notes are unchanged from the base branch. Examples and E2E modules are outside the published-module compatibility scope; this does not claim a complete workspace migration.

Validation on macOS arm64:

  • Fresh latest: moonc 0.10.20+65efd5b93.
  • Fresh pre-release: moonc 0.10.21+cfd6c5d6c.
  • On each channel, targeted native checks passed and all 41 existing tests in proton/updater, proton/internal/logging, sys/power_monitor, and config passed with the published xlog dependency.
  • On both channels, proton_package native and Wasm checks and executable builds passed; existing package tests passed 45/45 on native and 46/46 on Wasm, without updating expected outputs.
  • All 24 published modules passed moon check --target native,js,wasm,wasm-gc on both channels, using an external workspace listing the published modules and honoring their supported-target declarations. Pre-release reports 20 warnings (unused JSON imports and an existing deprecated conversion), but no errors.
  • On each channel, all 196 existing native tests across the CLI, CDP, filesystem/network extensions, and shell passed. All 94 existing CLI Wasm tests also passed, without updating expected outputs or adding tests.
  • CLI executable builds passed on native and Wasm on both channels.
  • Targeted moon info and moon fmt completed with no public interface changes.
  • On latest, the full workspace moon check --target native --deny-warn passed; moon info produced no interface changes relative to the base; moon fmt --check passed.
  • OpenSeek 0978a3d48, using this Proton source through an isolated workspace override, passed native check and linked its application on latest without consumer source changes.
  • OpenSeek pre-release PR #2520 at 22ef281f3 linked with this Proton source on current 0.10.21+cfd6c5d6c, using the unmodified published xlog@0.5.1 selected transitively by Proton. The validation copy still needs an independent two-line fix for the CDP host's removed http.get_text call. That consumer fix is not included here; the unmodified pre-release consumer still fails on it.

Linux watcher behavior, Windows runtime behavior, and GUI interaction were not exercised locally. The existing latest-channel CI covers the repository's platform checks; this PR does not claim that the entire Proton workspace builds on pre-release.

Pin CI and the publish workflow to MoonBit 0.10.21+f125caab5 (the
pre-release channel; `latest` still ships 0.10.20, whose core/async has
the old API) and migrate the workspace to the revised core/async API:

- power_monitor: core/async/pipe is gone. The Linux completion pipe is
  now opened by a C stub (pipe(2), close-on-exec, nonblocking read end)
  and the read end is wrapped in @raw_fd.RawFdStream; the write end is
  still handed to the native watcher. A whitebox test covers the
  POSIX pipe and stream EOF.
- http: connection-returning get is get_stream (updater, net download);
  one-shot get/post_binary/put_binary return MessageBody (net request,
  CDP discovery); flush is flush_partial_data.
- fs extension: read_text lost sync_timestamp. The contract field is
  kept and still honored by reading through File and syncing it.
- Read/write failures wrap their cause in TransportError; error details
  unwrap it so messages are unchanged.
- socket Addr port is a UInt16 field (dev readiness probe rejects
  out-of-range ports); mkdir allow_exist is allow_existing;
  read_exactly_at is File::at(..).read_exactly; ReaderClosed is
  UnexpectedEof.
- Platform is #non_exhaustive: shell raises ShellError for unknown
  platforms, config maps them to Linux.
- Drop moonbitlang/core/json imports the new compiler reports unused.

moon info regenerates derived from_json signatures (JsonPath ->
DecodeContext); moon fmt adds trailing commas. Release notes (en/zh)
record the toolchain requirement as unreleased.

Validation (0.10.21+f125caab5, macOS arm64):
- moon check --target native|js|wasm|wasm-gc --deny-warn
- moon test --target native --no-parallelize (845 passed)
- CI js/wasm test set (proton_client/rabbita/contract, codegen,
  package, cefsetup store)
- moon -C examples build / moon -C e2e build --target native
- node scripts/verify_generated.mjs; moon fmt --check; moon info clean
The isomorphic shared contract derives ToJson/FromJson without naming
@JSON, and 0.10.21 rejects the import under --deny-warn. This PR merges
only after 0.10.21 reaches stable, when template users are on it too.
Keep both Unreleased release-note entries: macOS occluded rendering
from main and the MoonBit 0.10.21 toolchain requirement.
Windows CI rejected the Linux completion-pipe helpers and the
core/async/types import as unused, because begin_watching had a
separate Windows variant. Use one begin_watching on every platform:
the pipe path stays gated at runtime on Linux, as it already was for
macOS, and the descriptor stub has a HANDLE signature on Windows that
the pipe path never reaches.
@tonyfettes tonyfettes changed the title chore(toolchain)!: build on MoonBit 0.10.21 core/async fix(async): keep app dependencies compatible across MoonBit channels Nov 13, 2026
@tonyfettes
tonyfettes marked this pull request as ready for review November 13, 2026 06:49
@tonyfettes tonyfettes changed the title fix(async): keep app dependencies compatible across MoonBit channels fix(async): support app and packaging builds across MoonBit channels Nov 13, 2026
@tonyfettes tonyfettes changed the title fix(async): support app and packaging builds across MoonBit channels fix(async): support published modules across MoonBit channels Nov 13, 2026
@tonyfettes
tonyfettes marked this pull request as draft November 13, 2026 07:27

This branch has not been deployed

No deployments
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