lmjtfy.git / third-party / rustcrates / cloud-mock-boat

cloud-mock-boat

Last changed

boat.dev as a cloud-mock world: an account's sandboxes behaving the way boat's documentation says, on a virtual clock, with every request and answer checked against boat's own OpenAPI document. It replaces jevgent's hand-written boat fake and drives the real sandbox-boat adapter, in-process or over a socket.

let mock = cloud_mock_boat::mock(cloud_mock_boat::DEFAULT_KEY);   // checked against the document
let boat = sandbox_boat::Boat::new(mock.io(), DEFAULT_KEY).with_base(mock.world(|w| w.api_url()));
// drive the adapter; its sleeps move the world's clock
mock.assert_conforms();

mock.world(|w| ...) reaches the world: w.config (durations, plan, balance, out_of_capacity), w.on_command(hook) to decide a command and how long it takes in virtual time, w.fail(id, why), w.take_deliveries() for signed webhook deliveries, w.set_origin(url) with a socket.

What is modelled

PartWhat
Lifecycleprovisioning, ready, archiving, archived, cloning, error; stop saves the disk and removes the machine, resume lands on a new machine with a new address and host key, fork copies the newest snapshot, recover, delete as a background operation
Auto-stopdefault one hour, ttlSeconds at create, resume and PATCH; a new deadline replaces the old; a stopped disk is kept 14 days (snapshot_data_expired)
Snapshotsone each minute after a write while running, one at every stop (not a forced one), named snapshots (saving, ready, a reused name replaces the old once ready), the sandbox's own list and its newest
Limitsrunning at once, starts per minute/hour/day, the trial, xlarge, balance (402), no capacity (503), failFast, idempotency keys, GET /limits, GET /sandboxes/{id}/usage
Machinecommands over a real sh on the sandbox's disk or scripted (waited for, timed out, detached, status, stop), files inline (5 MiB) and by signed URL, SSH keys and host keys, hosted ports; a command sent while the machine starts waits up to 60 s of virtual time
Commandswaited for, detached, streamed (application/x-ndjson), attached to by offset, stopped (a detached command shows nothing until it ends, unless its Finished::writing says what it had written by each moment, which GET commands/{id}?stdoutOffset=&stderrOffset= then returns as it goes); history with stored output; the process list; artifacts; 409 monitoring_off (src/commands.rs)
Account/me, organizations and the wallet new sandboxes bill, data retention (zero data retention, snapshots off and monitoring off, per account and per sandbox; a stop erases a snapshots-off sandbox), repositories, secrets, environments with immutable versions (a sandbox is pinned to one; upgrade moves it), the session token (403 session_required) (src/identity.rs)
Keysthe account key, scoped keys by action, sandbox and environment, TTL, rotate, revoke, usage; OpenTelemetry export; credential profiles; the AI credentials proxy and AI usage (src/keys.rs)
Agentsprompt, prompt status, conversations (parallel, one turn at a time in each), events with a cursor, steer (native or fallback by harness, 409 no_running_turn with its reason), interrupt (one conversation or all), provider_not_configured, scripted turns (src/agent.rs)
Sharing, desktopshare and unshare of an organization sandbox (shared/private, logins wiped at the next start), share codes of a named snapshot (shown once, from takes one, revoke), the desktop and noVNC URL (src/share.rs)
Snapshot contentsthe account-wide snapshot list, a snapshot's tree, a file with Range or a folder as a tar, signed download chunks, deleting one snapshot or all of a sandbox's with X-Ascii-Confirm-Delete (src/contents.rs)
Webhooksendpoints (HTTPS 443, ten at most, secret shown once, rotate), signed deliveries made at each state change and handed to the test
Contractspec/boat-v1.yaml (vendor's) and its JSON conversion; every request and answer under /api/v1 is checked

What is still 501

Nothing in the document: every operation is modelled. An operation the document does not have answers 501 naming it. The sweep test (src/tests_sweep.rs) walks the whole document and holds the (empty) list of operations that answer 501, and fails on any answer the document does not allow.

How the agent routes behave without a harness: a turn is scripted (BoatWorld::on_prompt gives a Reply: text, tool calls, how long it takes, or a failure); without a script the agent echoes the prompt after Config::agent_turn. The state machine, the event stream and its cursor, steering and interrupting follow docs.boat.dev/integrated-agents*.md (src/agent.rs).

Where the docs are silent

Searched 2026-10-21: the vendor's pages (primary: https://docs.boat.dev, the OpenAPI file) and a web search for the delete header, machine sizes and plan limits (nothing beyond the vendor: a listing site, https://www.toolify.ai/tool/boat, secondary, gives the $20 plan and the free trial only). Where nothing was found the mock's own choice is marked.

QuestionAnswerSource
A bash -lc commandruns as bash -c: a login shell would read this machine's own profile into the outputmock's choice
Error code of a delete without the confirm headerconfirm_delete (409)mock's choice; the status is the document's
Code of a command to a stopped or failing sandboxmachine_not_running, sandbox_error, sandbox_not_ready (409)machine_not_running is named by docs.boat.dev/api/v1.md for host; the rest the mock's choice
Code when a file is missingfile_not_found (404)the OpenAPI document
xlarge without the planmachine_type_not_available (403)mock's choice
Error codes, checked against docs.boat.dev/api/v1.md's error table (2026-10-25)unknown_environment (400), snapshots_disabled (409: resume, fork or save of a sandbox with snapshots off), provider_not_configured, sandbox_not_promptable, prompt_required, fast_mode_not_supported, no_running_turn (reasons turn_ended, turn_not_started, no_turn, not_running from the steer page), snapshot_not_foundthe vendor's pages (primary). The table gives the code, not always the operation that raises it: which operation raises snapshots_disabled is the mock's reading
Error codes the documents do not give (guesses)confirm_delete (409, a missing or wrong X-Ascii-Confirm-Delete; the status is the document's), invalid_conversation, conversation_not_found, prompt_not_found, invalid_provider, not_organization_sandbox, share_not_found, 416 range_not_satisfiable, interrupt of a sandbox with nothing running answering status: "idle"mock's choice
How many endpoints before a webhook is refusedten, webhook_limit_reached (409)the number is docs.boat.dev/webhooks.md (primary), the code the mock's
What a signed file URL looks like/_machine/{id}/file?path&method&exp&sig, a hash of a made-up secretmock's choice
Fork of a sandbox with no snapshot yet409 fork_failedmock's choice; the first snapshot is taken at ready
How long each transition takesprovision 3 s, clone 4 s, stop 4 s, hydrate 10 s, named save 40 s, delete 2 smock's choice, in Config
Start limitspaid 12/60/200, trial 5/25/75docs.boat.dev/limits.md for the paid and trial rows' shape; the numbers beyond the fixtures are the mock's
The wait after a rate limitin the body (window, limit); no Retry-After headerthe OpenAPI document and its error model

Files

PathWhat
src/world.rsstate, config, events, dispatch
src/sandboxes.rssandbox routes, the lifecycle and snapshots on the clock
src/machine.rscommands, files, signed URLs, SSH, ports
src/snapshots.rs, src/account.rsnamed snapshots; limits, webhooks, deliveries
src/commands.rscommands as boat keeps them: processes, history, streams, artifacts
src/agent.rs, src/share.rs, src/contents.rsthe integrated agents; sharing and the desktop; what a snapshot holds
src/identity.rs, src/keys.rsthe account, environments, retention; keys, telemetry, profiles, the AI proxy
src/tests_*.rsthe gaps, commands, account and the sweep over the whole document
src/spec.rs, spec/the contract and its pinned document (spec/SOURCE.md)
src/tests.rs, tests/adapter.rsthe world's own tests; the real adapter against the world