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, never start: PUT /v1/me/optin EngineOptinStopV1 → EngineOptinV1; active: true there is 403 forbidden_right reason owner_only.

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).
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_SCHEMA
ENGINE_OPTIN_STOP_SCHEMA
MAX_DAILY_TASKS
MAX_OPTIN_NETWORKS
MAX_OPTIN_VAULTS