Skip to main content

Crate lean_ctx_cloud

Crate lean_ctx_cloud 

Source
Expand description

LeanCTX | Cloud connector: the engine side of the contract in lean_ctx_protocol::cloud.

Rules every part keeps:

  • Local work is never gated: offline, disabled, a lapsed lease, a bus hold/stop/veto or a damaged control file only pause Cloud traffic (bus::control). The one exception is the organization’s verified policy (effective_floor): it is policy, not Cloud state, so its last valid rules keep applying offline and after not_after (lifting them would let a machine leave its policy by going offline), and a company-bound project is never mapped into a personal workspace (company_bound).
  • Cloud never blocks a tool call; network work runs in scheduler, in the in-process queue a tool call hands its Cloud requests to (background) or in explicit lean-ctx cloud … commands.
  • Every outbound content item passes knowledge::screening before it is queued in the outbox.
  • Tokens and keys never reach logs, Debug, errors or crash output.

Re-exports§

pub use config::CloudConfigExt;
pub use error::CloudError;
pub use error::Revocation;
pub use error::TaskRefusal;
pub use state::CloudStore;

Modules§

auth
Enrollment (device flow), access tokens and lease renewal.
background
Cloud requests a tool call hands off (connector rule “Cloud never blocks a tool call”).
bring_local
Bringing a project’s local work into the vault it was just linked to (lean-ctx cloud link --bring-local): its local tasks (crate::tasks::local) become proposed tasks of the vault, and its local doc pages (crate::local_docs) pages of the vault, once each.
bus
The cross-instance agent bus: the local bus (ctx_agent) of every machine of an organization joined through Cloud.
capture
Capture quality gate (Cloud v4 V1, SPEC-ENGINE §3.1).
company_bound
Personal beside the Company (owner decision 26.10.): a Personal workspace stays private and never belongs to a company, and a company may keep its teams’ project knowledge out of personal workspaces with the policy member sharing.personal_workspace: forbid (tighten-only, default allow).
computers
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.
config
[cloud] configuration: the section’s types come from lean_ctx::core::config::cloud; this module adds the Cloud’s origin and root-key rules.
connect
The steps of lean-ctx cloud connect after the device flow (CHECKLIST 2.1.1): the person confirms once per workspace what this machine shares with it, then the current project is mapped to its vault.
consent
Out-of-band consent (SPEC-ENGINE §3.8; C0 2.0 consent.schema.json, enums/consent-kinds.json, vectors/consent_*.vectors.json).
cpao
LeanCTX Cloud cost per accepted outcome (GET /v1/cpao, contract W2): what the team’s agents cost over the last 7 and 30 days, divided by the outcomes that were accepted (a landed merge request or an accepted task result), for a local reader such as LeanCTX Code.
delivery
Delivery of a place’s knowledge into an agent’s context (SPEC-ENGINE §3.5): which folded nodes a host session may see, in which bucket, and a deterministic rendering (#498) — the same replica and query give the same bytes, whatever the clock, the scores or the trust revision say.
disconnect
lean-ctx cloud disconnect: Cloud is told first, local data goes after.
docs
Docs in Cloud (C0 2.2): the engine adapter of lean_ctx_doc.
effective_floor
The Cloud effective policy as a floor of the gateway policy engine (Release B 3.1.4).
effective_policy
Unified Control on the engine (Release B 3.1.4, 3.1.6): receive, verify, apply and acknowledge the signed effective policy a 2.x Cloud adds to GET /v1/policy/bundle (effective_policy).
error
Errors of the Cloud connector. Messages are safe to print: they never carry tokens, keys, device codes or request bodies.
events
C0 2.0 events on the engine (Cloud v4 V4.1, SPEC-ENGINE §3.3): ids, the hybrid logical clock, signing and verification, and building events from what the capture gate let through. Worker and alias keys come from core/cloud/workers (ENGINE-2).
friction
Collaboration friction per hour (V16.1, RESOLUTIONS R128): the local friction log (core::agents::friction) summed for one closed hour per vault into the C0 2.0 counts of a collaboration finding (about: collaboration, counts, window; CONTRACT §3.19.2). Counts and ids only, never text.
gateway
LeanCTX Cloud model gateway key (POST /v1/gateway/key): a short-lived key with which this computer’s sessions run on models from LeanCTX, paid from the team’s balance.
identity_v2
Project identity v2 (CHECKLIST 2.1.2, design ee/delivery/cloud-v5-project-mapping.md): the same repository has the same identity on every device, built from the committed .lean-ctx-id, the normalized origin remote and the root commit. Never the local path.
instance_key
The instance’s long-lived keys: Ed25519 for token assertions and an X25519 key whose public half enrollment carries.
keyset_v3
Key set v3 (E13; C0 2.0 keyset.schema.json, vectors/keyset_v3.vectors.json; RESOLUTIONS R55 as amended by R103).
knowledge
Project knowledge with Cloud: session learnings stream out as draft proposals (draft), reviewed revisions stream back in (pull).
lease
Lease and key-set verification, renewal and the service clock offset.
link
lean-ctx cloud link <workspace>/<vault>[@<server>]: link a git repository to a vault.
local_docs
A project’s docs on this Instance alone (lean_ctx_doc::local): the store of a checkout that no vault is linked to. Keyed like knowledge (<data dir>/docs/<hash_project_root>), so the CLI, the MCP tool and Cloud Desktop find the same pages. Nothing here contacts Cloud.
mapping
Project → vault mapping and the first-share confirmation (CHECKLIST 2.1.2, 2.1.3; design ee/delivery/cloud-v5-project-mapping.md).
metrics
Local inputs of engine metrics v2: the time-ordered store readers they build on (collect) and the Cloud use counters they sample (cloud_use).
metrics_v2
Engine metrics v2: hourly counters of this engine for its Cloud workspace (POST /v1/metrics/hours, telemetry SPEC, owner checklist K1–K4, K15, K16).
migrate
Engine upgrade duties of the first 3.12 start (SPEC-ENGINE §3.16, V13.E1), from a 3.11.5 or a 3.12.0-rc data directory.
models_access
The subscription models through the Cloud models gateway (mz6, docs/model-access-subscription.md §4): the connector’s CloudTokenSource for the proxy’s built-in leanctx provider, and the catalog of lean-ctx models and of the Local Read kind cloud.models.catalog (read_catalog).
outbox
Durable outbox: everything bound for Cloud is written here first and sent later by the scheduler (or lean-ctx cloud sync), so Cloud never blocks a tool call and nothing is lost while offline.
policy
Filter packs from Cloud.
policy_sessions
Per-session enforcement evidence (3.12.3): which Cloud policy (version, digest, signature state) was in force for which app session, with the receipts made under it.
queens
Queen sessions: the sessions LeanCTX | Cloud Desktop started as a Queen, registered by the app over the 0600 local socket (an app-only call).
receipts
POST /v1/receipts (receipts v2, C0 2.5 K2 M3): the Engine receipts of this machine’s Cloud vaults.
replica
The engine’s offline replica of a place (Cloud v4 V4, SPEC-ENGINE §3.4): an encrypted SQLite store per place, the cursor into the server log, the queue of own events not yet in that log. Folding events and the sync routes follow the C0 2.0 wire shapes.
resolution
Local vault resolutions that no longer fit their checkout (dogfood 5.11.: one repository split across two vaults without a warning).
review
Reviewer and maintenance clients (SPEC-ENGINE §3.15, §3.15b).
revoked
The local record of a revocation (C0 2.0 E12, 401 instance_revoked).
root_cert
Trust in a self-hosted Cloud: the vendor’s root certificate (C0 1.7).
runners
CI runners on LeanCTX computers (/v1/runners, local-read-v1 §45): list, add and remove the GitHub Actions and GitLab runners LeanCTX Cloud runs for the person and their teams.
runtime_lease
The Cloud lease as the Intelligence runtime’s licence.
scheduler
Background Cloud work, started once at MCP startup.
session_ref
V9 session_ref: the session a write names, and whether the enrolled Cloud may hear it.
state
Durable Cloud state on this machine.
status
Local, network-free Cloud status: the cockpit’s cloud status --json shape and the human report behind lean-ctx cloud status.
sync
Engine sync with a place (Cloud v4 V4, SPEC-ENGINE §3.4.3–§3.4.4): verification of snapshot and tail records, the push of own events, and the driver that clones, tails and pushes a replica.
task_evidence
Task evidence (trace per change, contract §36): when this engine’s agent submits or verifies a Cloud task, the engine pins what it can prove about the work, so LeanCTX Cloud can join a landed change to its goal, the context its agent saw, and the rule that allowed it.
tasks
Tasks in the engine (H2, C0 1.9 §1): read a project’s tasks, claim one, report short summaries, submit one result with evidence, give it back.
team_decisions
Team rules for every agent of a vault (rc4-69).
team_stop
The team stop (kill switch) as the Cloud reports it to an engine (GET /v1/stop, acting as the person the instance is linked to).
throttle
Quota and policy throttles (Release B, Cloud API §7.2 and §8.1).
transport
HTTP transport to the Cloud engine API (<origin>/v1).
unlink
lean-ctx cloud unlink (rc4-6): stop sharing one project folder with its vault, on this machine only.
unlinked
<data_dir>/cloud/unlinked_roots.json (rc4-6): the project folders the person stopped sharing with cloud unlink. A folder listed here is never shared again on its own: it resolves no vault (also not through its main checkout or another checkout of the same repository), cloud sync and the knowledge sync do not map it, a write does not push it, a task proposal or message from it is not sent, and capture queues no draft for it. Only an explicit cloud link in the folder that Cloud accepts takes it out of the list.
untrusted
Foreign content as data (X5): every bus message, task body/update and repo fact pulled from Cloud that reaches an agent’s context passes wrap first.
usage
LeanCTX Cloud usage (GET /v1/usage): how far each quota of the workspace is used, so this machine warns at 80 % instead of meeting a refusal.
vault
Repository identity and the local map of resolved Cloud vaults.
vault_address
Vault addresses <ws>/<vault>[@<server>] (C0 2.0 common.schema.json $defs/vault_address, vectors/vault_address.vectors.json), used in .lean-ctx-cloud.json (link v2), CLI vault arguments and environment values. No server or @cloud.leanctx.com is the hosted service; a server with a dot or a port is self-hosted at https://<server>.
worker
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.
workers
Durable workers (SPEC-ENGINE §3.6, C0 2.0 section 2): the identity an agent has on Cloud instead of its process id.

Structs§

CloudConfig

Constants§

CLOUD_AVAILABLE
Release switch: the connector shipped switched off in 3.12.0 and 3.12.1 (cloud connect/cloud link refused, cloud hidden from help, suggestions and completions). Owner 2026-11-04: LeanCTX | Cloud opens with 3.12.2.
CLOUD_TOOLS
Cloud MCP tools. They ship with the connector but follow its release switch (available_locally, owner 28.10.): while it is off they are in no tool list and every call answers TOOL_NOT_AVAILABLE.
NOT_AVAILABLE
The one line cloud connect/cloud link print while the switch is off.
PREVIEW_ENV
Test switch: LEAN_CTX_CLOUD_PREVIEW=1 opens the connector before the release, for a loopback Cloud only (the FakeCloud of the test suite).
TOOL_NOT_AVAILABLE
The one line a call to a Cloud MCP tool (ctx_tasks) answers while the switch is off; the tools stay out of every tool list.

Functions§

available_for
Whether this engine may connect to the Cloud at origin.
available_locally
Whether Cloud commands that name no origin (cloud link) may run.
is_loopback
Whether origin names this machine (127.0.0.1, localhost, ::1).
register_hooks
Register the connector’s hooks into the engine. Every entry calls this at start-up, before the first tool call (cli::dispatch::run, next to proxy::register_shapers, and the lean-ctx-embed engine builder). Calling it again changes nothing: the first registration wins. Every hook here is bookkeeping or telemetry and decides no refusal, except the subscription-model token source (models_access): without it the proxy refuses the leanctx provider (fail closed). The sign-in probe answers a question: the managed cloud.require gate in the engine decides, and refuses when no probe is registered.