Skip to content

Expose package-owned worker jobs - #572

Draft
peter-jerry-ye wants to merge 1 commit into
mainfrom
codex/package-owned-job
Draft

Expose package-owned worker jobs#572
peter-jerry-ye wants to merge 1 commit into
mainfrom
codex/package-owned-job

Conversation

@peter-jerry-ye

@peter-jerry-ye peter-jerry-ye commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Why

Packages outside async need to offload blocking native or runtime work without duplicating event-loop notification and worker-pool lifecycle. The existing job type is internal, so those packages cannot submit their own opaque jobs through the shared scheduler.

What

  • Add a small moonbitlang/async/job package exposing an opaque, target-specific Job and a with_job submission interface.
  • Keep native job construction in the binding package and allow Wasm hosts to provide opaque job handles.
  • Run completion callbacks on the event-loop thread while the job and its structured result remain valid.

Why this shape

The public facade and event loop share the same Job type through a type-only leaf package. Native binding functions can therefore return the scheduler's exact opaque Job type directly, without exposing the event-loop package or requiring a representation cast. Wasm handle lowering remains private to the event-loop implementation.

The event loop learns only about an opaque job. It does not learn package-specific operations, result types, or concurrency policy. Notification, worker lifecycle, cancellation, and completion remain in their existing owners. Resource-specific coordination belongs to the submitting package.

@coveralls

coveralls commented Aug 25, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 1080

Coverage decreased (-0.02%) to 76.954%

Details

  • Coverage decreased (-0.02%) from the base build.
  • Patch coverage: 1 uncovered change across 1 file (4 of 5 lines covered, 80.0%).
  • 1 coverage regression across 1 file.

Uncovered Changes

File Changed Covered %
src/job/types/job.wasm.mbt 1 0 0.0%
Total (3 files) 5 4 80.0%

Coverage Regressions

1 previously-covered line in 1 file lost coverage.

File Lines Losing Coverage Coverage
src/internal/event_loop/process_unix.mbt 1 44.44%

Coverage Stats

Coverage Status
Relevant Lines: 4938
Covered Lines: 3800
Line Coverage: 76.95%
Coverage Strength: 12015.75 hits per line

💛 - Coveralls

@peter-jerry-ye
peter-jerry-ye force-pushed the codex/package-owned-job branch from 3938b39 to 65526cf Compare August 25, 2026 07:29
@peter-jerry-ye
peter-jerry-ye force-pushed the codex/package-owned-job branch 2 times, most recently from 60a0774 to f5dfe57 Compare August 25, 2026 08:36
@peter-jerry-ye peter-jerry-ye changed the title Support package-owned serialized worker jobs Expose package-owned worker jobs Aug 25, 2026
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