Skip to main content

Module worker

Module worker 

Source
Expand description

Worker mode (Cloud plan v3 L1, owner decision O1): the person’s own agent pulls tasks through MCP; the engine never starts an agent by itself.

Every claim and every result passes this gate first:

  • The engine’s opt-in lives on the server (GET /v1/me/optin): which vaults its agents may work on, whether it is active, and the daily budget. It is read fresh for every claim; when it cannot be read, nothing is claimed (fail closed).
  • The daily budget has three limits and the first one reached stops the work: tasks per day (checked before a claim), and optionally tokens and USD per day (counted from the usage each result reports; the result that crosses a limit still goes through, the next claim does not).
  • [cloud.worker] may only tighten these limits on this machine, never widen them.
  • cloud worker pause stops claiming here until resume, and held claims are no longer renewed (they end at their expiry); cloud worker stop also switches the opt-in off on the server, which ends every claim of this engine at once. Only the owner turns it on again, on the web.

Cloud enforces the same rules (C0 1.9 section 4: 403 optin_scope / vetoed, 409 optin_inactive / optin_changed, 429 daily_budget); this gate makes a refusal local and content-free instead of a request that would leak which task was attempted.

Structs§

Admission
An admitted claim: the opt-in it works under and what is left after it.
BudgetLeft
What is left of today’s budget; None is no limit.
CloudWorkerConfig
[cloud.worker]: stricter local caps on top of the server’s budget.
EvidenceSummary
What a result reports it cost, for today’s budget.
TaskScope
The task a claim or result is for.
Usage
What a day has used on this machine.
WorkerState
The local worker state: pause flag and what this machine used today.

Enums§

Limit
The limit a budget refusal hit.
Refusal
Why the gate refused; its text never names the task or its content.

Constants§

OPTIN_PATH
The engine’s own opt-in record (engine auth, own instance only).
PROVIDER_TERMS_NOTE
The provider-terms note every worker opt-in shows (plan X1; the web opt-in form carries the same text). LeanCTX never handles subscription credentials: the agent is one the person started and signed in to.

Functions§

admit_claim
Admit a claim: whether this machine may ask Cloud for it. Nothing is counted yet; count_claim counts it once Cloud granted it, so a claim Cloud refuses costs no task of today’s budget.
admit_claim_for
admit_claim on an opt-in the caller just read.
admit_submit
Add the usage a result reports to today’s.
count_claim
Count a claim Cloud granted (or a verification commit it took) against today’s tasks on this machine. A refused claim is never counted: it used to be, and refusals then ate the local budget until this machine refused on its own.
decide_claim
The claim decision on a read opt-in and the local state (no I/O).
fetch_optin
The server’s opt-in for this engine.
fetch_optin_via
The opt-in through client (a bounded client of a tool call).
read_state
The local state as stored (today’s counters reset on a new day). Fail closed: a file that cannot be read or parsed counts as paused, and so does a missing one on an engine enrolled with Cloud — deleting it never lifts a pause or resets today’s counts. Only enrollment (prepare_enrollment) and cloud worker resume, both of which the person runs (an agent shell refuses them), write it unpaused.
set_paused
Stop or resume claiming on this machine.
stop
Stop worker mode for this engine: pause here and switch the opt-in off on the server, which ends every claim of this engine at once.

Type Aliases§

Optin
The engine’s opt-in (C0 1.9 section 4).