Expand description
LeanCTX Cloud computers (/v1/computers, cloud design cloud-computer.md
§4.3): list, create, start and stop the computers of the person and of
their teams, for lean-ctx cloud computer … and LeanCTX Code.
The cloud enforces who may create or start a computer, its role, the free hours, the balance and the trial; this module only passes the request on and hands back what the cloud answered:
200/201/202with a row (or{computers: […]}) →Answer::Done;- an error with a code (
402 balance_empty,402 plan_required,403 forbidden,404 no_computer,409 computer_exists,409 computer_busy,400/422 invalid_request,429,428 confirmation_required,503 computer_provider_unavailable,503 computer_not_available) →Answer::Refused, with the cloud’s own message anderror.details; 404without a code, or503 not_configured, from a cloud that does not offer computers, and a list200 {available: false}(no provider yet) →Answer::NotOffered.
A create or a start costs money, so the CLI sends one only after the
person confirmed the terms (--yes), and always with confirm: true.
A cloud that still wants a confirmation answers
428 confirmation_required with the terms in error.details
({billing: free|billed, usd_per_hour, free_hours_left, topup_usd},
read with terms) and does nothing: a second guard.
Every exchange goes through an Exchange: connected for the connected
instance (the session refreshes a refused token), on_client for one
CloudClient.
No code and no file content is ever sent: the bodies carry only the request id, the name, the role, the team and the confirmation.
Structs§
- Computer
List GET /v1/computers, checked.- Create
Request POST /v1/computersbody ({ request_id, name, team?, role, confirm }). The cloud picks size and region and does not stop an idle computer, so the CLI offers no size, region or idle stop: a computer runs, and is billed, until it is stopped.- Refusal
- The cloud refused the request; passed on as it said it.
- RunStart
Request POST /v1/computers/{id}/startbody forlean-ctx run --cloud(contract §35). A run is billed from the first minute (free hours are only forweave_host), so this body exists only after the person confirmed the terms (--yes, or yes at the prompt):confirmis alwaystrue. Carries no code, no task text, no file content.- Terms
- The terms of a billable write, from a
428 confirmation_required(error.details): one shape for the cloud, the CLI and LeanCTX Code.
Enums§
- Answer
- What the cloud said.
- Transition
- A start or a stop.
Constants§
- MAX_
ROWS - Most rows kept from a list.
- ROLES
- The roles a computer is created with; fixed at create.
- ROLE_
GENERAL - The role of any other computer; the only one for a personal account.
- ROLE_
WEAVE_ HOST - The role the free Team hours apply to (owner, 18.11.).
Functions§
- connected
- The exchanges of the connected instance: each one through its session, which refreshes a refused token.
- create
POST /v1/computers: the new row (provisioning).- list
GET /v1/computers.- new_
request_ id - A fresh request id: a retry of the same command passes it again with
--request-id, and the cloud answers the first answer. - on_
client - The exchanges on
client. - run_
terms - The terms of a run on computer
row, from the list row alone (no request to the cloud): billed from the first minute, at the row’s price (else its balance’s), with what is left of the top-up as listed (topup_usd).purpose: "run"is alwaysbilled: the free hours are a team’sweave_host’s, never a run’s. A malformed value isNone, never a guess. - start_
basis - Who pays a start, from the row the cloud answered (§3.3), in the words
of
Terms::billing: a team’sweave_hostcomputer with free hours left starts on them (free); a personal computer never does (the free hours are the team’s) and ageneralone never does: they arebilled(paid from the top-up). A team’sweave_hostwhose row carries no readablebalance.free_hours_leftisNone: unknown, never guessed. The cloud decides; this only names it. - start_
for_ run POST /v1/computers/{id}/startfor a confirmed run (seeRunStartRequest): the row (starting, orrunningwhen it already ran), or the cloud’s refusal.- terms
- The terms in
details; anything malformed isNone, never a guess. - transition
POST /v1/computers/{id}/startor/stop: the row (startingorstopping).confirm(start only) as inCreateRequest::confirm.- valid_
id - A computer id as the cloud sends it (
cmp_…), safe in a path. - valid_
request_ id - A request id the cloud accepts: 8-64 of
A-Z a-z 0-9 _ -.
Type Aliases§
- Exchange
- One exchange with the cloud: method, path (under
/v1) and body → the HTTP status and the JSON answer.