Skip to content

feat(compute): Morph microVM backend + pre-warm pool for the computer plane - #953

Merged
mercurialsolo merged 1 commit into
mainfrom
feat/morph-compute-backend
Jun 30, 2026
Merged

mercurialsolo merged 1 commit into
mainfrom
feat/morph-compute-backend

Conversation

@mercurialsolo

Copy link
Copy Markdown
Owner

What

Adds Morph (morph.so) as a 5th compute-plane backend (local/modal/e2b/
daytona/morph), plus a pre-warm pool that eliminates cold-start
latency. This is the legitimate latency/reliability use of Morph's instant-
snapshot microVMs — explicitly not anything to do with bot-detection.

Pieces

  • gym/morph_impl.MorphComputerImpl (extends RemoteComputerImpl, mirrors
    E2BComputerImpl): start an instance from a snapshot → expose HTTP service →
    await /health → delegate the screenshot+xdotool wire. Two modes:
    • provision — fresh instance, torn down on close()
    • claim — a pre-booted instance+base_url from the pool (pool owns its
      lifecycle, not torn down by the run)
      All morphcloud-SDK calls are isolated in injectable, getattr-guarded helpers
      → tests use a fake SDK, zero real API calls.
  • gym/morph_prewarm_pool.MorphPrewarmPool: keeps size booted +
    health-checked instances ready; acquire() pops one instantly + refills in
    the background; release()/drain() stop instances (single-use — a run
    mutates VM state). refill_async=False for deterministic tests.
  • computer_client: backend="morph" dispatch (claim from morph_pool
    when set, else provision from morph_snapshot_id); config fields threaded
    through resolve_for_executor.
  • pyproject: optional morph extra.

Tests

test_morph_impl.py (5) + test_morph_prewarm_pool.py (5): provision / claim /
health-timeout-teardown / missing-creds; pool top_up / acquire-hot /
cold-miss / release / drain. 54 compute-plane tests green; ruff clean.

Activation (operational follow-up — not in this PR)

This backend is inert until selected (default stays local/modal). To turn
it on: build a Morph snapshot of the computer-plane image (Xvfb + Chrome +
screenshot/xdotool service on :8000 with /health), set
MANTIS_MORPH_SNAPSHOT + MORPH_API_KEY, construct a MorphPrewarmPool at
server startup, and set backend="morph". Verify the exact morphcloud SDK
method names against the installed version first
— they're isolated in the
helpers, so any drift is a one-line fix.

🤖 Generated with Claude Code

… plane

Adds Morph (morph.so) as a 5th compute-plane backend alongside
local/modal/e2b/daytona, plus a pre-warm pool that eliminates cold-start
latency. This is the legitimate latency/reliability use of Morph's instant-
snapshot microVMs — it has nothing to do with bot-detection.

- gym/morph_impl.MorphComputerImpl(RemoteComputerImpl): mirrors E2BComputerImpl
  — start an instance from a snapshot, expose its HTTP service, await /health,
  delegate the screenshot+xdotool wire to RemoteComputerImpl, tear down on
  close(). Two modes: provision (fresh) or claim (pre-booted instance+base_url
  from the pool, not torn down on close). All morphcloud-SDK calls isolated in
  injectable, getattr-guarded helpers so tests use a fake SDK.
- gym/morph_prewarm_pool.MorphPrewarmPool: keeps `size` booted+health-checked
  instances ready; acquire() pops one instantly + refills in the background;
  release()/drain() stop instances (single-use — runs mutate VM state).
- computer_client: backend="morph" dispatch (claim from cfg.morph_pool when set,
  else provision from cfg.morph_snapshot_id); new config fields threaded through
  resolve_for_executor; "morph" added to the ComputerPlaneBackend Literal.
- pyproject: optional `morph` extra (morphcloud).

Tests: test_morph_impl.py (5) + test_morph_prewarm_pool.py (5) — provision/
claim/timeout-teardown/missing-creds; pool top_up/acquire-hot/cold-miss/release/
drain. 54 compute-plane tests green; ruff clean.

Activation (operational follow-up, not in this PR): build a Morph snapshot of
the computer-plane image (Xvfb+Chrome+screenshot/xdotool service on :8000 with
/health), set MANTIS_MORPH_SNAPSHOT + MORPH_API_KEY, construct a MorphPrewarmPool
at server startup, and set backend="morph". Verify the exact morphcloud SDK
method names against the installed version first.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mercurialsolo
mercurialsolo merged commit 69af1a6 into main Jun 30, 2026
6 checks passed
@mercurialsolo
mercurialsolo deleted the feat/morph-compute-backend branch June 30, 2026 13:33
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