Skip to main content

Module optin

Module optin 

Source
Expand description

Engine opt-in (C0 1.9, section 4; owner decision O1).

An engine’s agents work on tasks only by pulling them, and only within the opt-in its owner set on the web: which vaults and networks, how much per day, and whether at all. Cloud never starts an agent; nothing here spawns anything.

GET /v1/me/optin (instance token) → EngineOptinV1. The owner changes it on the web; every change gets a new optin_id, and active: false (the stop) ends every claim of that engine at once. The engine may stop itself: PUT /v1/me/optin EngineOptinStopV1 → EngineOptinV1. It turns task pickup on only with the person at the computer (rc4-16): PUT /v1/me/optin EngineOptinOnV1, signed with the app’s bound opt-in key (no per-turn-on prompt) over OPTIN_SIGNING_DOMAIN ‖ canonical JSON of the body without presence_signature, plus instance_id. Only the bound opt-in key signs it; there is no presence-key fallback. The instance token alone never turns it on (403 forbidden_right reason person_unproven); without a bound opt-in key the engine refuses it before sending (no_optin_key: pair LeanCTX Code with the computer first). Turning it off needs no key.

Cloud is the source of truth and enforces it on every claim:

  • a claim carries the optin_id the engine last read (section 1 TaskClaimRequestV1.optin_id, required since this section; without it 400 invalid_request field optin_id);
  • an older optin_id → 409 invalid_state reason optin_changed: the engine reads the opt-in again before it pulls;
  • active: false, or no opt-in → 409 invalid_state reason optin_inactive;
  • a vault or network outside the opt-in → 403 forbidden_right reason optin_scope;
  • the day’s budget used up → 429 rate_limited reason daily_budget, with limit, used (claims) and retry_after_s until 00:00 UTC.

Usage counts per UTC day: a claim counts one task when it is granted; the usage of task results (section 1) adds tokens and usd_micros. A claim is refused once any set limit is reached; a running claim is never cut short by the budget. A granted claim counts atomically: parallel claims of one engine never exceed daily_budget.tasks together.

An engine may apply stricter local caps (fewer tasks, a lower budget, a narrower scope). It never widens what Cloud allows.

Structs§

DailyBudgetV1
Limits per UTC day. A limit that is absent is no limit; since Cloud task #19 (owner decision 23.10.) that holds for the task count too.
DailyUsageV1
What the engine used today (UTC).
EngineOptinOnV1
PUT /v1/me/optin: task pickup turned on from the computer, with the person at it (rc4-16). presence_signature is the signature of the app’s bound opt-in key only (never the presence key; the field keeps its name on the wire) (base64url, no padding) over OPTIN_SIGNING_DOMAIN ‖ canonical JSON of the body without it, plus "instance_id" (the instance UUID, lowercase with hyphens). Cloud refuses a prev_optin_id that is not the opt-in’s current one (409 invalid_state reason optin_changed), so a signature works at most once.
EngineOptinStopV1
PUT /v1/me/optin: the engine’s own stop.
EngineOptinV1
GET /v1/me/optin.

Enums§

NetworkV1
A network an engine may pull questions from: an org channel (org:<org_id>/vault:<vault_id>/<name>). Any other kind does not decode.

Constants§

DEFAULT_DAILY_TASKS
ENGINE_OPTIN_ON_SCHEMA
PUT /v1/me/optin with active: true (rc4-16).
ENGINE_OPTIN_SCHEMA
ENGINE_OPTIN_STOP_SCHEMA
MAX_DAILY_TASKS
MAX_OPTIN_NETWORKS
MAX_OPTIN_VAULTS
OPTIN_SIGNING_DOMAIN
The domain the person’s presence signature of a turn-on is made under.